mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
Blockchain cache pruning strategy (#3395)
* blockchain cache pruning strategy * added some internal docs to cache_pruning_strategy * Update core/client/db/src/cache/mod.rs Co-Authored-By: DemiMarie-parity <48690212+DemiMarie-parity@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
d105d3f3a1
commit
eba6dd73c6
@@ -25,7 +25,8 @@ use sr_primitives::{generic::BlockId, Justification, StorageOverlay, ChildrenSto
|
||||
use sr_primitives::traits::{Block as BlockT, NumberFor};
|
||||
use state_machine::backend::Backend as StateBackend;
|
||||
use state_machine::{ChangesTrieStorage as StateChangesTrieStorage, ChangesTrieTransaction};
|
||||
use consensus::{well_known_cache_keys, BlockOrigin};
|
||||
use crate::blockchain::well_known_cache_keys;
|
||||
use consensus::BlockOrigin;
|
||||
use hash_db::Hasher;
|
||||
use parking_lot::Mutex;
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ use std::sync::Arc;
|
||||
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor};
|
||||
use sr_primitives::generic::BlockId;
|
||||
use sr_primitives::Justification;
|
||||
use consensus::well_known_cache_keys;
|
||||
|
||||
use crate::error::{Error, Result};
|
||||
|
||||
@@ -254,3 +253,18 @@ pub fn tree_route<Block: BlockT, F: Fn(BlockId<Block>) -> Result<<Block as Block
|
||||
pivot,
|
||||
})
|
||||
}
|
||||
|
||||
/// A list of all well known keys in the blockchain cache.
|
||||
pub mod well_known_cache_keys {
|
||||
/// The type representing cache keys.
|
||||
pub type Id = consensus::import_queue::CacheKeyId;
|
||||
|
||||
/// A list of authorities.
|
||||
pub const AUTHORITIES: Id = *b"auth";
|
||||
|
||||
/// Current Epoch data.
|
||||
pub const EPOCH: Id = *b"epch";
|
||||
|
||||
/// Changes trie configuration.
|
||||
pub const CHANGES_TRIE_CONFIG: Id = *b"chtr";
|
||||
}
|
||||
|
||||
@@ -49,7 +49,6 @@ use executor::{RuntimeVersion, RuntimeInfo};
|
||||
use consensus::{
|
||||
Error as ConsensusError, BlockImportParams,
|
||||
ImportResult, BlockOrigin, ForkChoiceStrategy,
|
||||
well_known_cache_keys::Id as CacheKeyId,
|
||||
SelectChain, self,
|
||||
};
|
||||
|
||||
@@ -65,6 +64,7 @@ use crate::{
|
||||
blockchain::{
|
||||
self, Info as ChainInfo, Backend as ChainBackend,
|
||||
HeaderBackend as ChainHeaderBackend, ProvideCache, Cache,
|
||||
well_known_cache_keys::Id as CacheKeyId,
|
||||
},
|
||||
call_executor::{CallExecutor, LocalCallExecutor},
|
||||
notifications::{StorageNotifications, StorageEventStream},
|
||||
|
||||
@@ -27,13 +27,12 @@ use state_machine::backend::{Backend as StateBackend, InMemory};
|
||||
use state_machine::{self, InMemoryChangesTrieStorage, ChangesTrieAnchorBlockId, ChangesTrieTransaction};
|
||||
use hash_db::{Hasher, Prefix};
|
||||
use trie::MemoryDB;
|
||||
use consensus::well_known_cache_keys::Id as CacheKeyId;
|
||||
|
||||
use crate::error;
|
||||
use crate::backend::{self, NewBlockState, StorageCollection, ChildStorageCollection};
|
||||
use crate::light;
|
||||
use crate::leaves::LeafSet;
|
||||
use crate::blockchain::{self, BlockStatus, HeaderBackend};
|
||||
use crate::blockchain::{self, BlockStatus, HeaderBackend, well_known_cache_keys::Id as CacheKeyId};
|
||||
|
||||
struct PendingBlock<B: BlockT> {
|
||||
block: StoredBlock<B>,
|
||||
|
||||
@@ -124,6 +124,8 @@ pub use crate::notifications::{StorageEventStream, StorageChangeSet};
|
||||
pub use state_machine::ExecutionStrategy;
|
||||
#[cfg(feature = "std")]
|
||||
pub use crate::leaves::LeafSet;
|
||||
#[cfg(feature = "std")]
|
||||
pub use crate::blockchain::well_known_cache_keys;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use sr_api_macros::{decl_runtime_apis, impl_runtime_apis};
|
||||
|
||||
@@ -29,12 +29,11 @@ use crate::backend::{
|
||||
AuxStore, Backend as ClientBackend, BlockImportOperation, RemoteBackend, NewBlockState,
|
||||
StorageCollection, ChildStorageCollection,
|
||||
};
|
||||
use crate::blockchain::HeaderBackend as BlockchainHeaderBackend;
|
||||
use crate::blockchain::{HeaderBackend as BlockchainHeaderBackend, well_known_cache_keys};
|
||||
use crate::error::{Error as ClientError, Result as ClientResult};
|
||||
use crate::light::blockchain::{Blockchain, Storage as BlockchainStorage};
|
||||
use hash_db::Hasher;
|
||||
use trie::MemoryDB;
|
||||
use consensus::well_known_cache_keys;
|
||||
|
||||
const IN_MEMORY_EXPECT_PROOF: &str = "InMemory state backend has Void error type and always succeeds; qed";
|
||||
|
||||
|
||||
@@ -22,11 +22,13 @@ use std::{sync::Arc, collections::HashMap};
|
||||
|
||||
use sr_primitives::{Justification, generic::BlockId};
|
||||
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor, Zero};
|
||||
use consensus::well_known_cache_keys;
|
||||
|
||||
use crate::backend::{AuxStore, NewBlockState};
|
||||
use crate::blockchain::{Backend as BlockchainBackend, BlockStatus, Cache as BlockchainCache,
|
||||
HeaderBackend as BlockchainHeaderBackend, Info as BlockchainInfo, ProvideCache};
|
||||
use crate::blockchain::{
|
||||
Backend as BlockchainBackend, BlockStatus, Cache as BlockchainCache,
|
||||
HeaderBackend as BlockchainHeaderBackend, Info as BlockchainInfo, ProvideCache,
|
||||
well_known_cache_keys,
|
||||
};
|
||||
use crate::cht;
|
||||
use crate::error::{Error as ClientError, Result as ClientResult};
|
||||
use crate::light::fetcher::{Fetcher, RemoteHeaderRequest};
|
||||
|
||||
Reference in New Issue
Block a user