mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 22:51:13 +00:00
Remove the dependency on heapsize (#2459)
* Remove heapsize dependency * Finish removing heapsize * Revert accidental change * Fix Cargo.lock
This commit is contained in:
committed by
Gavin Wood
parent
9fdd7df582
commit
5a820db7f5
@@ -19,7 +19,6 @@
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use parity_codec::Decode;
|
||||
use hash_db::Hasher;
|
||||
use heapsize::HeapSizeOf;
|
||||
use crate::backend::Backend;
|
||||
use crate::overlayed_changes::OverlayedChanges;
|
||||
use crate::trie_backend_essence::{TrieBackendStorage, TrieBackendEssence};
|
||||
@@ -44,7 +43,6 @@ pub fn prepare_input<'a, B, S, H>(
|
||||
S: Storage<H>,
|
||||
&'a S: TrieBackendStorage<H>,
|
||||
H: Hasher,
|
||||
H::Out: HeapSizeOf,
|
||||
{
|
||||
let (storage, config) = match (storage, changes.changes_trie_config.as_ref()) {
|
||||
(Some(storage), Some(config)) => (storage, config),
|
||||
@@ -110,7 +108,7 @@ fn prepare_digest_input<'a, S, H>(
|
||||
S: Storage<H>,
|
||||
&'a S: TrieBackendStorage<H>,
|
||||
H: Hasher,
|
||||
H::Out: 'a + HeapSizeOf,
|
||||
H::Out: 'a,
|
||||
{
|
||||
let mut digest_map = BTreeMap::<Vec<u8>, BTreeSet<u64>>::new();
|
||||
for digest_build_block in digest_build_iterator(config, parent.number + 1) {
|
||||
|
||||
@@ -21,7 +21,6 @@ use std::cell::RefCell;
|
||||
use std::collections::VecDeque;
|
||||
use parity_codec::{Decode, Encode};
|
||||
use hash_db::{HashDB, Hasher};
|
||||
use heapsize::HeapSizeOf;
|
||||
use trie::{Recorder, MemoryDB};
|
||||
use crate::changes_trie::{AnchorBlockId, Configuration, RootsStorage, Storage};
|
||||
use crate::changes_trie::input::{DigestIndex, ExtrinsicIndex, DigestIndexValue, ExtrinsicIndexValue};
|
||||
@@ -39,7 +38,7 @@ pub fn key_changes<'a, S: Storage<H>, H: Hasher>(
|
||||
end: &'a AnchorBlockId<H::Out>,
|
||||
max: u64,
|
||||
key: &'a [u8],
|
||||
) -> Result<DrilldownIterator<'a, S, S, H>, String> where H::Out: HeapSizeOf {
|
||||
) -> Result<DrilldownIterator<'a, S, S, H>, String> {
|
||||
// we can't query any roots before root
|
||||
let max = ::std::cmp::min(max, end.number);
|
||||
|
||||
@@ -69,7 +68,7 @@ pub fn key_changes_proof<S: Storage<H>, H: Hasher>(
|
||||
end: &AnchorBlockId<H::Out>,
|
||||
max: u64,
|
||||
key: &[u8],
|
||||
) -> Result<Vec<Vec<u8>>, String> where H::Out: HeapSizeOf {
|
||||
) -> Result<Vec<Vec<u8>>, String> {
|
||||
// we can't query any roots before root
|
||||
let max = ::std::cmp::min(max, end.number);
|
||||
|
||||
@@ -109,7 +108,7 @@ pub fn key_changes_proof_check<S: RootsStorage<H>, H: Hasher>(
|
||||
end: &AnchorBlockId<H::Out>,
|
||||
max: u64,
|
||||
key: &[u8]
|
||||
) -> Result<Vec<(u64, u32)>, String> where H::Out: HeapSizeOf {
|
||||
) -> Result<Vec<(u64, u32)>, String> {
|
||||
// we can't query any roots before root
|
||||
let max = ::std::cmp::min(max, end.number);
|
||||
|
||||
@@ -278,7 +277,6 @@ pub struct DrilldownIterator<'a, RS: 'a + RootsStorage<H>, S: 'a + Storage<H>, H
|
||||
|
||||
impl<'a, RS: 'a + RootsStorage<H>, S: Storage<H>, H: Hasher> Iterator
|
||||
for DrilldownIterator<'a, RS, S, H>
|
||||
where H::Out: HeapSizeOf
|
||||
{
|
||||
type Item = Result<(u64, u32), String>;
|
||||
|
||||
@@ -305,7 +303,7 @@ impl<'a, RS: 'a + RootsStorage<H>, S: Storage<H>, H: Hasher> ProvingDrilldownIte
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, RS: 'a + RootsStorage<H>, S: Storage<H>, H: Hasher> Iterator for ProvingDrilldownIterator<'a, RS, S, H> where H::Out: HeapSizeOf {
|
||||
impl<'a, RS: 'a + RootsStorage<H>, S: Storage<H>, H: Hasher> Iterator for ProvingDrilldownIterator<'a, RS, S, H> {
|
||||
type Item = Result<(u64, u32), String>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
|
||||
@@ -47,7 +47,6 @@ pub use self::changes_iterator::{key_changes, key_changes_proof, key_changes_pro
|
||||
pub use self::prune::{prune, oldest_non_pruned_trie};
|
||||
|
||||
use hash_db::Hasher;
|
||||
use heapsize::HeapSizeOf;
|
||||
use crate::backend::Backend;
|
||||
use primitives;
|
||||
use crate::changes_trie::build::prepare_input;
|
||||
@@ -93,7 +92,7 @@ pub fn compute_changes_trie_root<'a, B: Backend<H>, S: Storage<H>, H: Hasher>(
|
||||
) -> Option<(H::Out, Vec<(Vec<u8>, Vec<u8>)>)>
|
||||
where
|
||||
&'a S: TrieBackendStorage<H>,
|
||||
H::Out: Ord + HeapSizeOf,
|
||||
H::Out: Ord,
|
||||
{
|
||||
let input_pairs = prepare_input::<B, S, H>(backend, storage, changes, parent)
|
||||
.expect("storage is not allowed to fail within runtime")?;
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
//! Changes trie pruning-related functions.
|
||||
|
||||
use hash_db::Hasher;
|
||||
use heapsize::HeapSizeOf;
|
||||
use trie::Recorder;
|
||||
use log::warn;
|
||||
use crate::proving_backend::ProvingBackendEssence;
|
||||
@@ -53,8 +52,6 @@ pub fn prune<S: Storage<H>, H: Hasher, F: FnMut(H::Out)>(
|
||||
current_block: &AnchorBlockId<H::Out>,
|
||||
mut remove_trie_node: F,
|
||||
)
|
||||
where
|
||||
H::Out: HeapSizeOf,
|
||||
{
|
||||
// select range for pruning
|
||||
let (first, last) = match pruning_range(config, min_blocks_to_keep, current_block.number) {
|
||||
@@ -169,10 +166,7 @@ mod tests {
|
||||
storage: &S,
|
||||
min_blocks_to_keep: u64,
|
||||
current_block: u64,
|
||||
) -> HashSet<H::Out>
|
||||
where
|
||||
H::Out: HeapSizeOf,
|
||||
{
|
||||
) -> HashSet<H::Out> {
|
||||
let mut pruned_trie_nodes = HashSet::new();
|
||||
prune(config, storage, min_blocks_to_keep, &AnchorBlockId { hash: Default::default(), number: current_block },
|
||||
|node| { pruned_trie_nodes.insert(node); });
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
use std::collections::HashMap;
|
||||
use hash_db::Hasher;
|
||||
use trie::DBValue;
|
||||
use heapsize::HeapSizeOf;
|
||||
use trie::MemoryDB;
|
||||
use parking_lot::RwLock;
|
||||
use crate::changes_trie::{AnchorBlockId, RootsStorage, Storage};
|
||||
@@ -33,7 +32,7 @@ use crate::backend::insert_into_memory_db;
|
||||
use crate::changes_trie::input::InputPair;
|
||||
|
||||
/// In-memory implementation of changes trie storage.
|
||||
pub struct InMemoryStorage<H: Hasher> where H::Out: HeapSizeOf {
|
||||
pub struct InMemoryStorage<H: Hasher> {
|
||||
data: RwLock<InMemoryStorageData<H>>,
|
||||
}
|
||||
|
||||
@@ -43,12 +42,12 @@ pub struct TrieBackendAdapter<'a, H: Hasher, S: 'a + Storage<H>> {
|
||||
_hasher: ::std::marker::PhantomData<H>,
|
||||
}
|
||||
|
||||
struct InMemoryStorageData<H: Hasher> where H::Out: HeapSizeOf {
|
||||
struct InMemoryStorageData<H: Hasher> {
|
||||
roots: HashMap<u64, H::Out>,
|
||||
mdb: MemoryDB<H>,
|
||||
}
|
||||
|
||||
impl<H: Hasher> InMemoryStorage<H> where H::Out: HeapSizeOf {
|
||||
impl<H: Hasher> InMemoryStorage<H> {
|
||||
/// Create the storage from given in-memory database.
|
||||
pub fn with_db(mdb: MemoryDB<H>) -> Self {
|
||||
Self {
|
||||
@@ -109,13 +108,13 @@ impl<H: Hasher> InMemoryStorage<H> where H::Out: HeapSizeOf {
|
||||
}
|
||||
}
|
||||
|
||||
impl<H: Hasher> RootsStorage<H> for InMemoryStorage<H> where H::Out: HeapSizeOf {
|
||||
impl<H: Hasher> RootsStorage<H> for InMemoryStorage<H> {
|
||||
fn root(&self, _anchor_block: &AnchorBlockId<H::Out>, block: u64) -> Result<Option<H::Out>, String> {
|
||||
Ok(self.data.read().roots.get(&block).cloned())
|
||||
}
|
||||
}
|
||||
|
||||
impl<H: Hasher> Storage<H> for InMemoryStorage<H> where H::Out: HeapSizeOf {
|
||||
impl<H: Hasher> Storage<H> for InMemoryStorage<H> {
|
||||
fn get(&self, key: &H::Out, prefix: &[u8]) -> Result<Option<DBValue>, String> {
|
||||
MemoryDB::<H>::get(&self.data.read().mdb, key, prefix)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user