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
@@ -21,9 +21,8 @@ use sr_primitives::Justification;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use crate::well_known_cache_keys;
|
||||
|
||||
use crate::import_queue::Verifier;
|
||||
use crate::import_queue::{Verifier, CacheKeyId};
|
||||
|
||||
/// Block import result.
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
@@ -182,7 +181,7 @@ pub trait BlockImport<B: BlockT> {
|
||||
fn import_block(
|
||||
&mut self,
|
||||
block: BlockImportParams<B>,
|
||||
cache: HashMap<well_known_cache_keys::Id, Vec<u8>>,
|
||||
cache: HashMap<CacheKeyId, Vec<u8>>,
|
||||
) -> Result<ImportResult, Self::Error>;
|
||||
}
|
||||
|
||||
@@ -202,7 +201,7 @@ where for<'r> &'r T: BlockImport<B, Error = E>
|
||||
fn import_block(
|
||||
&mut self,
|
||||
block: BlockImportParams<B>,
|
||||
cache: HashMap<well_known_cache_keys::Id, Vec<u8>>,
|
||||
cache: HashMap<CacheKeyId, Vec<u8>>,
|
||||
) -> Result<ImportResult, Self::Error> {
|
||||
(&**self).import_block(block, cache)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
use sr_primitives::{Justification, traits::{Block as BlockT, Header as _, NumberFor}};
|
||||
use crate::{error::Error as ConsensusError, well_known_cache_keys::Id as CacheKeyId};
|
||||
use crate::error::Error as ConsensusError;
|
||||
use crate::block_import::{
|
||||
BlockImport, BlockOrigin, BlockImportParams, ImportedAux, JustificationImport, ImportResult,
|
||||
FinalityProofImport,
|
||||
@@ -65,6 +65,9 @@ pub struct IncomingBlock<B: BlockT> {
|
||||
pub origin: Option<Origin>,
|
||||
}
|
||||
|
||||
/// Type of keys in the blockchain cache that consensus module could use for its needs.
|
||||
pub type CacheKeyId = [u8; 4];
|
||||
|
||||
/// Verify a justification of a block
|
||||
pub trait Verifier<B: BlockT>: Send + Sync {
|
||||
/// Verify the given data and return the BlockImportParams and an optional
|
||||
|
||||
@@ -117,15 +117,3 @@ where T: ?Sized, for<'r> &'r T: SyncOracle
|
||||
<&T>::is_offline(&mut &**self)
|
||||
}
|
||||
}
|
||||
|
||||
/// A list of all well known keys in the cache.
|
||||
pub mod well_known_cache_keys {
|
||||
/// The type representing cache keys.
|
||||
pub type Id = [u8; 4];
|
||||
|
||||
/// A list of authorities.
|
||||
pub const AUTHORITIES: Id = *b"auth";
|
||||
|
||||
/// Current Epoch data.
|
||||
pub const EPOCH: Id = *b"epch";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user