mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 00:01:09 +00:00
Use [u8; 4] for well known cache keys (#2152)
* Use [u8; 4] for well known cache keys * Use type alias
This commit is contained in:
committed by
DemiMarie-parity
parent
3dfda381d5
commit
fbbd79e778
@@ -20,6 +20,7 @@ use runtime_primitives::traits::{Block as BlockT, DigestItemFor, Header as Heade
|
||||
use runtime_primitives::Justification;
|
||||
use std::borrow::Cow;
|
||||
use std::collections::HashMap;
|
||||
use crate::well_known_cache_keys;
|
||||
|
||||
/// Block import result.
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
@@ -182,7 +183,7 @@ pub trait BlockImport<B: BlockT> {
|
||||
fn import_block(
|
||||
&self,
|
||||
block: ImportBlock<B>,
|
||||
cache: HashMap<Vec<u8>, Vec<u8>>,
|
||||
cache: HashMap<well_known_cache_keys::Id, Vec<u8>>,
|
||||
) -> Result<ImportResult, Self::Error>;
|
||||
}
|
||||
|
||||
|
||||
@@ -570,7 +570,7 @@ pub fn import_single_block<B: BlockT, V: Verifier<B>>(
|
||||
|
||||
let mut cache = HashMap::new();
|
||||
if let Some(authorities) = new_authorities {
|
||||
cache.insert(crate::well_known_cache_keys::AUTHORITIES.to_vec(), authorities.encode());
|
||||
cache.insert(crate::well_known_cache_keys::AUTHORITIES, authorities.encode());
|
||||
}
|
||||
|
||||
import_error(import_handle.import_block(import_block, cache))
|
||||
|
||||
@@ -120,6 +120,9 @@ impl<T: SyncOracle> SyncOracle for Arc<T> {
|
||||
|
||||
/// 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: &'static [u8] = b"auth";
|
||||
pub const AUTHORITIES: Id = *b"auth";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user