mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-15 03:21:06 +00:00
Fix tons of warnings in newest nightly (#2784)
* Fix tons of warnings in newest nightly * Fix sr-api-macro doc tests
This commit is contained in:
+3
-3
@@ -97,19 +97,19 @@ pub struct DbColumns {
|
||||
pub struct DbStorage {
|
||||
name: Vec<u8>,
|
||||
meta_key: Vec<u8>,
|
||||
db: Arc<KeyValueDB>,
|
||||
db: Arc<dyn KeyValueDB>,
|
||||
columns: DbColumns,
|
||||
}
|
||||
|
||||
impl DbStorage {
|
||||
/// Create new database-backed list cache storage.
|
||||
pub fn new(name: Vec<u8>, db: Arc<KeyValueDB>, columns: DbColumns) -> Self {
|
||||
pub fn new(name: Vec<u8>, db: Arc<dyn KeyValueDB>, columns: DbColumns) -> Self {
|
||||
let meta_key = meta::key(&name);
|
||||
DbStorage { name, meta_key, db, columns }
|
||||
}
|
||||
|
||||
/// Get reference to the database.
|
||||
pub fn db(&self) -> &Arc<KeyValueDB> { &self.db }
|
||||
pub fn db(&self) -> &Arc<dyn KeyValueDB> { &self.db }
|
||||
|
||||
/// Get reference to the database columns.
|
||||
pub fn columns(&self) -> &DbColumns { &self.columns }
|
||||
|
||||
+3
-3
@@ -77,7 +77,7 @@ impl<T> CacheItemT for T where T: Clone + Decode + Encode + PartialEq {}
|
||||
/// Database-backed blockchain data cache.
|
||||
pub struct DbCache<Block: BlockT> {
|
||||
cache_at: HashMap<CacheKeyId, ListCache<Block, Vec<u8>, self::list_storage::DbStorage>>,
|
||||
db: Arc<KeyValueDB>,
|
||||
db: Arc<dyn KeyValueDB>,
|
||||
key_lookup_column: Option<u32>,
|
||||
header_column: Option<u32>,
|
||||
authorities_column: Option<u32>,
|
||||
@@ -88,7 +88,7 @@ pub struct DbCache<Block: BlockT> {
|
||||
impl<Block: BlockT> DbCache<Block> {
|
||||
/// Create new cache.
|
||||
pub fn new(
|
||||
db: Arc<KeyValueDB>,
|
||||
db: Arc<dyn KeyValueDB>,
|
||||
key_lookup_column: Option<u32>,
|
||||
header_column: Option<u32>,
|
||||
authorities_column: Option<u32>,
|
||||
@@ -150,7 +150,7 @@ impl<Block: BlockT> DbCache<Block> {
|
||||
fn get_cache_helper<'a, Block: BlockT>(
|
||||
cache_at: &'a mut HashMap<CacheKeyId, ListCache<Block, Vec<u8>, self::list_storage::DbStorage>>,
|
||||
name: CacheKeyId,
|
||||
db: &Arc<KeyValueDB>,
|
||||
db: &Arc<dyn KeyValueDB>,
|
||||
key_lookup: Option<u32>,
|
||||
header: Option<u32>,
|
||||
cache: Option<u32>,
|
||||
|
||||
@@ -70,7 +70,7 @@ const CANONICALIZATION_DELAY: u64 = 4096;
|
||||
const MIN_BLOCKS_TO_KEEP_CHANGES_TRIES_FOR: u32 = 32768;
|
||||
|
||||
/// DB-backed patricia trie state, transaction type is an overlay of changes to commit.
|
||||
pub type DbState = state_machine::TrieBackend<Arc<state_machine::Storage<Blake2Hasher>>, Blake2Hasher>;
|
||||
pub type DbState = state_machine::TrieBackend<Arc<dyn state_machine::Storage<Blake2Hasher>>, Blake2Hasher>;
|
||||
|
||||
pub struct RefTrackingState<Block: BlockT> {
|
||||
state: DbState,
|
||||
@@ -213,7 +213,7 @@ struct PendingBlock<Block: BlockT> {
|
||||
}
|
||||
|
||||
// wrapper that implements trait required for state_db
|
||||
struct StateMetaDb<'a>(&'a KeyValueDB);
|
||||
struct StateMetaDb<'a>(&'a dyn KeyValueDB);
|
||||
|
||||
impl<'a> state_db::MetaDb for StateMetaDb<'a> {
|
||||
type Error = io::Error;
|
||||
@@ -225,13 +225,13 @@ impl<'a> state_db::MetaDb for StateMetaDb<'a> {
|
||||
|
||||
/// Block database
|
||||
pub struct BlockchainDb<Block: BlockT> {
|
||||
db: Arc<KeyValueDB>,
|
||||
db: Arc<dyn KeyValueDB>,
|
||||
meta: Arc<RwLock<Meta<NumberFor<Block>, Block::Hash>>>,
|
||||
leaves: RwLock<LeafSet<Block::Hash, NumberFor<Block>>>,
|
||||
}
|
||||
|
||||
impl<Block: BlockT> BlockchainDb<Block> {
|
||||
fn new(db: Arc<KeyValueDB>) -> Result<Self, client::error::Error> {
|
||||
fn new(db: Arc<dyn KeyValueDB>) -> Result<Self, client::error::Error> {
|
||||
let meta = read_meta::<Block>(&*db, columns::META, columns::HEADER)?;
|
||||
let leaves = LeafSet::read_from_db(&*db, columns::META, meta_keys::LEAF_PREFIX)?;
|
||||
Ok(BlockchainDb {
|
||||
@@ -340,7 +340,7 @@ impl<Block: BlockT> client::blockchain::Backend<Block> for BlockchainDb<Block> {
|
||||
Ok(self.meta.read().finalized_hash.clone())
|
||||
}
|
||||
|
||||
fn cache(&self) -> Option<Arc<client::blockchain::Cache<Block>>> {
|
||||
fn cache(&self) -> Option<Arc<dyn client::blockchain::Cache<Block>>> {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -354,7 +354,7 @@ impl<Block: BlockT> client::blockchain::Backend<Block> for BlockchainDb<Block> {
|
||||
}
|
||||
|
||||
impl<Block: BlockT> client::blockchain::ProvideCache<Block> for BlockchainDb<Block> {
|
||||
fn cache(&self) -> Option<Arc<client::blockchain::Cache<Block>>> {
|
||||
fn cache(&self) -> Option<Arc<dyn client::blockchain::Cache<Block>>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -473,7 +473,7 @@ where Block: BlockT<Hash=H256>,
|
||||
}
|
||||
|
||||
struct StorageDb<Block: BlockT> {
|
||||
pub db: Arc<KeyValueDB>,
|
||||
pub db: Arc<dyn KeyValueDB>,
|
||||
pub state_db: StateDb<Block::Hash, Vec<u8>>,
|
||||
}
|
||||
|
||||
@@ -512,7 +512,7 @@ impl state_machine::Storage<Blake2Hasher> for DbGenesisStorage {
|
||||
}
|
||||
|
||||
pub struct DbChangesTrieStorage<Block: BlockT> {
|
||||
db: Arc<KeyValueDB>,
|
||||
db: Arc<dyn KeyValueDB>,
|
||||
meta: Arc<RwLock<Meta<NumberFor<Block>, Block::Hash>>>,
|
||||
min_blocks_to_keep: Option<u32>,
|
||||
_phantom: ::std::marker::PhantomData<Block>,
|
||||
@@ -693,7 +693,12 @@ impl<Block: BlockT<Hash=H256>> Backend<Block> {
|
||||
).expect("failed to create test-db")
|
||||
}
|
||||
|
||||
fn from_kvdb(db: Arc<KeyValueDB>, pruning: PruningMode, canonicalization_delay: u64, state_cache_size: usize) -> Result<Self, client::error::Error> {
|
||||
fn from_kvdb(
|
||||
db: Arc<dyn KeyValueDB>,
|
||||
pruning: PruningMode,
|
||||
canonicalization_delay: u64,
|
||||
state_cache_size: usize
|
||||
) -> Result<Self, client::error::Error> {
|
||||
let is_archive_pruning = pruning.is_archive();
|
||||
let blockchain = BlockchainDb::new(db.clone())?;
|
||||
let meta = blockchain.meta.clone();
|
||||
|
||||
@@ -59,7 +59,7 @@ const CHANGES_TRIE_CHT_PREFIX: u8 = 1;
|
||||
/// Light blockchain storage. Stores most recent headers + CHTs for older headers.
|
||||
/// Locks order: meta, leaves, cache.
|
||||
pub struct LightStorage<Block: BlockT> {
|
||||
db: Arc<KeyValueDB>,
|
||||
db: Arc<dyn KeyValueDB>,
|
||||
meta: RwLock<Meta<NumberFor<Block>, Block::Hash>>,
|
||||
leaves: RwLock<LeafSet<Block::Hash, NumberFor<Block>>>,
|
||||
cache: Arc<DbCacheSync<Block>>,
|
||||
@@ -96,7 +96,7 @@ impl<Block> LightStorage<Block>
|
||||
Self::from_kvdb(db as Arc<_>).expect("failed to create test-db")
|
||||
}
|
||||
|
||||
fn from_kvdb(db: Arc<KeyValueDB>) -> ClientResult<Self> {
|
||||
fn from_kvdb(db: Arc<dyn KeyValueDB>) -> ClientResult<Self> {
|
||||
let meta = read_meta::<Block>(&*db, columns::META, columns::HEADER)?;
|
||||
let leaves = LeafSet::read_from_db(&*db, columns::META, meta_keys::LEAF_PREFIX)?;
|
||||
let cache = DbCache::new(
|
||||
@@ -557,7 +557,7 @@ impl<Block> LightBlockchainStorage<Block> for LightStorage<Block>
|
||||
Ok(self.meta.read().finalized_hash.clone())
|
||||
}
|
||||
|
||||
fn cache(&self) -> Option<Arc<BlockchainCache<Block>>> {
|
||||
fn cache(&self) -> Option<Arc<dyn BlockchainCache<Block>>> {
|
||||
Some(self.cache.clone())
|
||||
}
|
||||
}
|
||||
@@ -888,7 +888,7 @@ pub(crate) mod tests {
|
||||
map
|
||||
}
|
||||
|
||||
fn get_authorities(cache: &BlockchainCache<Block>, at: BlockId<Block>) -> Option<Vec<AuthorityId>> {
|
||||
fn get_authorities(cache: &dyn BlockchainCache<Block>, at: BlockId<Block>) -> Option<Vec<AuthorityId>> {
|
||||
cache.get_at(&well_known_cache_keys::AUTHORITIES, &at).and_then(|val| Decode::decode(&mut &val[..]))
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
//! Db-based backend utility structures and functions, used by both
|
||||
//! full and light storages.
|
||||
|
||||
use std::sync::Arc;
|
||||
use std::io;
|
||||
use std::convert::TryInto;
|
||||
use std::{io, convert::TryInto, sync::Arc};
|
||||
|
||||
use kvdb::{KeyValueDB, DBTransaction};
|
||||
#[cfg(feature = "kvdb-rocksdb")]
|
||||
@@ -171,7 +169,7 @@ pub fn insert_hash_to_key_mapping<N: TryInto<u32>, H: AsRef<[u8]> + Clone>(
|
||||
/// block lookup key is the DB-key header, block and justification are stored under.
|
||||
/// looks up lookup key by hash from DB as necessary.
|
||||
pub fn block_id_to_lookup_key<Block>(
|
||||
db: &KeyValueDB,
|
||||
db: &dyn KeyValueDB,
|
||||
key_lookup_col: Option<u32>,
|
||||
id: BlockId<Block>
|
||||
) -> Result<Option<Vec<u8>>, client::error::Error> where
|
||||
@@ -197,7 +195,11 @@ pub fn db_err(err: io::Error) -> client::error::Error {
|
||||
|
||||
/// Open RocksDB database.
|
||||
#[cfg(feature = "kvdb-rocksdb")]
|
||||
pub fn open_database(config: &DatabaseSettings, col_meta: Option<u32>, db_type: &str) -> client::error::Result<Arc<KeyValueDB>> {
|
||||
pub fn open_database(
|
||||
config: &DatabaseSettings,
|
||||
col_meta: Option<u32>,
|
||||
db_type: &str
|
||||
) -> client::error::Result<Arc<dyn KeyValueDB>> {
|
||||
let mut db_config = DatabaseConfig::with_columns(Some(NUM_COLUMNS));
|
||||
db_config.memory_budget = config.cache_size;
|
||||
let path = config.path.to_str().ok_or_else(|| client::error::Error::Backend("Invalid database path".into()))?;
|
||||
@@ -222,7 +224,12 @@ pub fn open_database(config: &DatabaseSettings, col_meta: Option<u32>, db_type:
|
||||
}
|
||||
|
||||
/// Read database column entry for the given block.
|
||||
pub fn read_db<Block>(db: &KeyValueDB, col_index: Option<u32>, col: Option<u32>, id: BlockId<Block>) -> client::error::Result<Option<DBValue>>
|
||||
pub fn read_db<Block>(
|
||||
db: &dyn KeyValueDB,
|
||||
col_index: Option<u32>,
|
||||
col: Option<u32>,
|
||||
id: BlockId<Block>
|
||||
) -> client::error::Result<Option<DBValue>>
|
||||
where
|
||||
Block: BlockT,
|
||||
{
|
||||
@@ -234,7 +241,7 @@ pub fn read_db<Block>(db: &KeyValueDB, col_index: Option<u32>, col: Option<u32>,
|
||||
|
||||
/// Read a header from the database.
|
||||
pub fn read_header<Block: BlockT>(
|
||||
db: &KeyValueDB,
|
||||
db: &dyn KeyValueDB,
|
||||
col_index: Option<u32>,
|
||||
col: Option<u32>,
|
||||
id: BlockId<Block>,
|
||||
@@ -252,7 +259,7 @@ pub fn read_header<Block: BlockT>(
|
||||
|
||||
/// Required header from the database.
|
||||
pub fn require_header<Block: BlockT>(
|
||||
db: &KeyValueDB,
|
||||
db: &dyn KeyValueDB,
|
||||
col_index: Option<u32>,
|
||||
col: Option<u32>,
|
||||
id: BlockId<Block>,
|
||||
@@ -262,7 +269,7 @@ pub fn require_header<Block: BlockT>(
|
||||
}
|
||||
|
||||
/// Read meta from the database.
|
||||
pub fn read_meta<Block>(db: &KeyValueDB, col_meta: Option<u32>, col_header: Option<u32>) -> Result<
|
||||
pub fn read_meta<Block>(db: &dyn KeyValueDB, col_meta: Option<u32>, col_header: Option<u32>) -> Result<
|
||||
Meta<<<Block as BlockT>::Header as HeaderT>::Number, Block::Hash>,
|
||||
client::error::Error,
|
||||
>
|
||||
|
||||
@@ -81,7 +81,7 @@ pub trait Backend<Block: BlockT>: HeaderBackend<Block> {
|
||||
/// Get last finalized block hash.
|
||||
fn last_finalized(&self) -> Result<Block::Hash>;
|
||||
/// Returns data cache reference, if it is enabled on this backend.
|
||||
fn cache(&self) -> Option<Arc<Cache<Block>>>;
|
||||
fn cache(&self) -> Option<Arc<dyn Cache<Block>>>;
|
||||
|
||||
/// Returns hashes of all blocks that are leaves of the block tree.
|
||||
/// in other words, that have no children, are chain heads.
|
||||
@@ -95,7 +95,7 @@ pub trait Backend<Block: BlockT>: HeaderBackend<Block> {
|
||||
/// Provides access to the optional cache.
|
||||
pub trait ProvideCache<Block: BlockT> {
|
||||
/// Returns data cache reference, if it is enabled on this backend.
|
||||
fn cache(&self) -> Option<Arc<Cache<Block>>>;
|
||||
fn cache(&self) -> Option<Arc<dyn Cache<Block>>>;
|
||||
}
|
||||
|
||||
/// Blockchain optional data cache.
|
||||
|
||||
@@ -125,7 +125,7 @@ where
|
||||
let trie_state = state.as_trie_backend()
|
||||
.ok_or_else(||
|
||||
Box::new(state_machine::ExecutionError::UnableToGenerateProof)
|
||||
as Box<state_machine::Error>
|
||||
as Box<dyn state_machine::Error>
|
||||
)?;
|
||||
self.prove_at_trie_state(trie_state, overlay, method, call_data)
|
||||
}
|
||||
@@ -246,7 +246,7 @@ where
|
||||
let trie_state = state.as_trie_backend()
|
||||
.ok_or_else(||
|
||||
Box::new(state_machine::ExecutionError::UnableToGenerateProof)
|
||||
as Box<state_machine::Error>
|
||||
as Box<dyn state_machine::Error>
|
||||
)?;
|
||||
|
||||
let backend = state_machine::ProvingBackend::new_with_recorder(
|
||||
|
||||
@@ -26,7 +26,7 @@ use std::hash::Hash;
|
||||
pub fn read_children<
|
||||
K: Eq + Hash + Clone + Encode + Decode,
|
||||
V: Eq + Hash + Clone + Encode + Decode,
|
||||
>(db: &KeyValueDB, column: Option<u32>, prefix: &[u8], parent_hash: K) -> error::Result<Vec<V>> {
|
||||
>(db: &dyn KeyValueDB, column: Option<u32>, prefix: &[u8], parent_hash: K) -> error::Result<Vec<V>> {
|
||||
let mut buf = prefix.to_vec();
|
||||
parent_hash.using_encoded(|s| buf.extend(s));
|
||||
|
||||
@@ -116,6 +116,6 @@ mod tests {
|
||||
let r2: Vec<u32> = read_children(&db, None, PREFIX, 1_2).unwrap();
|
||||
|
||||
assert_eq!(r1, vec![1_3, 1_5]);
|
||||
assert_eq!(r2.len(), 0);
|
||||
assert_eq!(r2.len(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,7 +564,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
cht_size: NumberFor<Block>,
|
||||
) -> error::Result<ChangesProof<Block::Header>> {
|
||||
struct AccessedRootsRecorder<'a, Block: BlockT> {
|
||||
storage: &'a ChangesTrieStorage<Blake2Hasher, NumberFor<Block>>,
|
||||
storage: &'a dyn ChangesTrieStorage<Blake2Hasher, NumberFor<Block>>,
|
||||
min: NumberFor<Block>,
|
||||
required_roots_proofs: Mutex<BTreeMap<NumberFor<Block>, H256>>,
|
||||
};
|
||||
@@ -695,7 +695,7 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
|
||||
/// Create a new block, built on the head of the chain.
|
||||
pub fn new_block(
|
||||
&self,
|
||||
&self,
|
||||
inherent_digests: DigestFor<Block>,
|
||||
) -> error::Result<block_builder::BlockBuilder<Block, Self>> where
|
||||
E: Clone + Send + Sync,
|
||||
@@ -708,8 +708,8 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
|
||||
/// Create a new block, built on top of `parent`.
|
||||
pub fn new_block_at(
|
||||
&self,
|
||||
parent: &BlockId<Block>,
|
||||
&self,
|
||||
parent: &BlockId<Block>,
|
||||
inherent_digests: DigestFor<Block>,
|
||||
) -> error::Result<block_builder::BlockBuilder<Block, Self>> where
|
||||
E: Clone + Send + Sync,
|
||||
@@ -726,8 +726,8 @@ impl<B, E, Block, RA> Client<B, E, Block, RA> where
|
||||
/// These recorded trie nodes can be used by a third party to proof the
|
||||
/// output of this block builder without having access to the full storage.
|
||||
pub fn new_block_at_with_proof_recording(
|
||||
&self,
|
||||
parent: &BlockId<Block>,
|
||||
&self,
|
||||
parent: &BlockId<Block>,
|
||||
inherent_digests: DigestFor<Block>,
|
||||
) -> error::Result<block_builder::BlockBuilder<Block, Self>> where
|
||||
E: Clone + Send + Sync,
|
||||
@@ -1319,7 +1319,7 @@ impl<B, E, Block, RA> ProvideCache<Block> for Client<B, E, Block, RA> where
|
||||
B: backend::Backend<Block, Blake2Hasher>,
|
||||
Block: BlockT<Hash=H256>,
|
||||
{
|
||||
fn cache(&self) -> Option<Arc<Cache<Block>>> {
|
||||
fn cache(&self) -> Option<Arc<dyn Cache<Block>>> {
|
||||
self.backend.blockchain().cache()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ pub enum Error {
|
||||
ApplyExtrinsicFailed(ApplyError),
|
||||
/// Execution error.
|
||||
#[display(fmt = "Execution: {}", _0)]
|
||||
Execution(Box<state_machine::Error>),
|
||||
Execution(Box<dyn state_machine::Error>),
|
||||
/// Blockchain error.
|
||||
#[display(fmt = "Blockchain: {}", _0)]
|
||||
Blockchain(Box<Error>),
|
||||
@@ -100,7 +100,7 @@ pub enum Error {
|
||||
}
|
||||
|
||||
impl error::Error for Error {
|
||||
fn source(&self) -> Option<&(error::Error + 'static)> {
|
||||
fn source(&self) -> Option<&(dyn error::Error + 'static)> {
|
||||
match self {
|
||||
Error::Consensus(e) => Some(e),
|
||||
Error::Blockchain(e) => Some(e),
|
||||
@@ -128,7 +128,7 @@ impl Error {
|
||||
}
|
||||
|
||||
/// Chain a state error.
|
||||
pub fn from_state(e: Box<state_machine::Error + Send>) -> Self {
|
||||
pub fn from_state(e: Box<dyn state_machine::Error + Send>) -> Self {
|
||||
Error::Execution(e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +343,7 @@ impl<Block: BlockT> blockchain::Backend<Block> for Blockchain<Block> {
|
||||
Ok(self.storage.read().finalized_hash.clone())
|
||||
}
|
||||
|
||||
fn cache(&self) -> Option<Arc<blockchain::Cache<Block>>> {
|
||||
fn cache(&self) -> Option<Arc<dyn blockchain::Cache<Block>>> {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ impl<Block: BlockT> blockchain::Backend<Block> for Blockchain<Block> {
|
||||
}
|
||||
|
||||
impl<Block: BlockT> blockchain::ProvideCache<Block> for Blockchain<Block> {
|
||||
fn cache(&self) -> Option<Arc<blockchain::Cache<Block>>> {
|
||||
fn cache(&self) -> Option<Arc<dyn blockchain::Cache<Block>>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
@@ -433,7 +433,7 @@ impl<Block: BlockT> light::blockchain::Storage<Block> for Blockchain<Block>
|
||||
.ok_or_else(|| error::Error::Backend(format!("Changes trie CHT for block {} not exists", block)))
|
||||
}
|
||||
|
||||
fn cache(&self) -> Option<Arc<blockchain::Cache<Block>>> {
|
||||
fn cache(&self) -> Option<Arc<dyn blockchain::Cache<Block>>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ impl<H, N> LeafSet<H, N> where
|
||||
}
|
||||
|
||||
/// Read the leaf list from the DB, using given prefix for keys.
|
||||
pub fn read_from_db(db: &KeyValueDB, column: Option<u32>, prefix: &[u8]) -> error::Result<Self> {
|
||||
pub fn read_from_db(db: &dyn KeyValueDB, column: Option<u32>, prefix: &[u8]) -> error::Result<Self> {
|
||||
let mut storage = BTreeMap::new();
|
||||
|
||||
for (key, value) in db.iter_from_prefix(column, prefix) {
|
||||
|
||||
@@ -70,7 +70,7 @@ pub trait Storage<Block: BlockT>: AuxStore + BlockchainHeaderBackend<Block> {
|
||||
) -> ClientResult<Block::Hash>;
|
||||
|
||||
/// Get storage cache.
|
||||
fn cache(&self) -> Option<Arc<BlockchainCache<Block>>>;
|
||||
fn cache(&self) -> Option<Arc<dyn BlockchainCache<Block>>>;
|
||||
}
|
||||
|
||||
/// Light client blockchain.
|
||||
@@ -175,7 +175,7 @@ impl<S, F, Block> BlockchainBackend<Block> for Blockchain<S, F> where Block: Blo
|
||||
self.storage.last_finalized()
|
||||
}
|
||||
|
||||
fn cache(&self) -> Option<Arc<BlockchainCache<Block>>> {
|
||||
fn cache(&self) -> Option<Arc<dyn BlockchainCache<Block>>> {
|
||||
self.storage.cache()
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ impl<S, F, Block> BlockchainBackend<Block> for Blockchain<S, F> where Block: Blo
|
||||
}
|
||||
|
||||
impl<S: Storage<Block>, F, Block: BlockT> ProvideCache<Block> for Blockchain<S, F> {
|
||||
fn cache(&self) -> Option<Arc<BlockchainCache<Block>>> {
|
||||
fn cache(&self) -> Option<Arc<dyn BlockchainCache<Block>>> {
|
||||
self.storage.cache()
|
||||
}
|
||||
}
|
||||
@@ -303,7 +303,7 @@ pub mod tests {
|
||||
).into())
|
||||
}
|
||||
|
||||
fn cache(&self) -> Option<Arc<BlockchainCache<Block>>> {
|
||||
fn cache(&self) -> Option<Arc<dyn BlockchainCache<Block>>> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,7 +400,7 @@ pub fn prove_execution<Block, S, E>(
|
||||
E: CallExecutor<Block, Blake2Hasher>,
|
||||
{
|
||||
let trie_state = state.as_trie_backend()
|
||||
.ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) as Box<state_machine::Error>)?;
|
||||
.ok_or_else(|| Box::new(state_machine::ExecutionError::UnableToGenerateProof) as Box<dyn state_machine::Error>)?;
|
||||
|
||||
// prepare execution environment + record preparation proof
|
||||
let mut changes = Default::default();
|
||||
|
||||
@@ -620,7 +620,7 @@ pub mod tests {
|
||||
#[test]
|
||||
fn storage_read_proof_is_generated_and_checked() {
|
||||
let (local_checker, remote_block_header, remote_read_proof, authorities_len) = prepare_for_read_proof_check();
|
||||
assert_eq!((&local_checker as &FetchChecker<Block>).check_read_proof(&RemoteReadRequest::<Header> {
|
||||
assert_eq!((&local_checker as &dyn FetchChecker<Block>).check_read_proof(&RemoteReadRequest::<Header> {
|
||||
block: remote_block_header.hash(),
|
||||
header: remote_block_header,
|
||||
key: well_known_keys::AUTHORITY_COUNT.to_vec(),
|
||||
@@ -631,7 +631,7 @@ pub mod tests {
|
||||
#[test]
|
||||
fn header_proof_is_generated_and_checked() {
|
||||
let (local_checker, local_cht_root, remote_block_header, remote_header_proof) = prepare_for_header_proof_check(true);
|
||||
assert_eq!((&local_checker as &FetchChecker<Block>).check_header_proof(&RemoteHeaderRequest::<Header> {
|
||||
assert_eq!((&local_checker as &dyn FetchChecker<Block>).check_header_proof(&RemoteHeaderRequest::<Header> {
|
||||
cht_root: local_cht_root,
|
||||
block: 1,
|
||||
retry_count: None,
|
||||
@@ -642,7 +642,7 @@ pub mod tests {
|
||||
fn check_header_proof_fails_if_cht_root_is_invalid() {
|
||||
let (local_checker, _, mut remote_block_header, remote_header_proof) = prepare_for_header_proof_check(true);
|
||||
remote_block_header.number = 100;
|
||||
assert!((&local_checker as &FetchChecker<Block>).check_header_proof(&RemoteHeaderRequest::<Header> {
|
||||
assert!((&local_checker as &dyn FetchChecker<Block>).check_header_proof(&RemoteHeaderRequest::<Header> {
|
||||
cht_root: Default::default(),
|
||||
block: 1,
|
||||
retry_count: None,
|
||||
@@ -653,7 +653,7 @@ pub mod tests {
|
||||
fn check_header_proof_fails_if_invalid_header_provided() {
|
||||
let (local_checker, local_cht_root, mut remote_block_header, remote_header_proof) = prepare_for_header_proof_check(true);
|
||||
remote_block_header.number = 100;
|
||||
assert!((&local_checker as &FetchChecker<Block>).check_header_proof(&RemoteHeaderRequest::<Header> {
|
||||
assert!((&local_checker as &dyn FetchChecker<Block>).check_header_proof(&RemoteHeaderRequest::<Header> {
|
||||
cht_root: local_cht_root,
|
||||
block: 1,
|
||||
retry_count: None,
|
||||
@@ -667,7 +667,7 @@ pub mod tests {
|
||||
Arc::new(DummyBlockchain::new(DummyStorage::new())),
|
||||
test_client::LocalExecutor::new(None)
|
||||
);
|
||||
let local_checker = &local_checker as &FetchChecker<Block>;
|
||||
let local_checker = &local_checker as &dyn FetchChecker<Block>;
|
||||
let max = remote_client.info().chain.best_number;
|
||||
let max_hash = remote_client.info().chain.best_hash;
|
||||
|
||||
@@ -763,7 +763,7 @@ pub mod tests {
|
||||
Arc::new(DummyBlockchain::new(DummyStorage::new())),
|
||||
test_client::LocalExecutor::new(None)
|
||||
);
|
||||
let local_checker = &local_checker as &FetchChecker<Block>;
|
||||
let local_checker = &local_checker as &dyn FetchChecker<Block>;
|
||||
let max = remote_client.info().chain.best_number;
|
||||
let max_hash = remote_client.info().chain.best_hash;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user