Ethereum-types and various libs upgrade (#315)
* Upgrade Eth types ethereum-types -> 0.9.2 rlp -> 0.4.6 keccak-hash -> 0.5.0 parity-crypto -> 0.6.2 ethabi -> 0.12.0 ethabi-derive -> 0.12.0 ethabi-contract -> 0.11.0 ethbloom -> 0.9.1 rand -> 0.7.3 trie-standardmap -> 0.15.2 triehash -> 0.5.0 * backport #10714. Small changes, merge fixes Co-authored-by: mdben1247 <mdben1247@users.noreply.github.com>
This commit is contained in:
@@ -18,29 +18,29 @@
|
||||
//! crate.
|
||||
// TODO: push changes upstream in a clean way.
|
||||
|
||||
extern crate heapsize;
|
||||
extern crate lru_cache;
|
||||
extern crate parity_util_mem;
|
||||
|
||||
use heapsize::HeapSizeOf;
|
||||
use lru_cache::LruCache;
|
||||
use parity_util_mem::{MallocSizeOf, MallocSizeOfExt};
|
||||
|
||||
use std::hash::Hash;
|
||||
|
||||
const INITIAL_CAPACITY: usize = 4;
|
||||
|
||||
/// An LRU-cache which operates on memory used.
|
||||
pub struct MemoryLruCache<K: Eq + Hash, V: HeapSizeOf> {
|
||||
pub struct MemoryLruCache<K: Eq + Hash, V> {
|
||||
inner: LruCache<K, V>,
|
||||
cur_size: usize,
|
||||
max_size: usize,
|
||||
}
|
||||
|
||||
// amount of memory used when the item will be put on the heap.
|
||||
fn heap_size_of<T: HeapSizeOf>(val: &T) -> usize {
|
||||
::std::mem::size_of::<T>() + val.heap_size_of_children()
|
||||
fn heap_size_of<T: MallocSizeOf>(val: &T) -> usize {
|
||||
::std::mem::size_of::<T>() + val.malloc_size_of()
|
||||
}
|
||||
|
||||
impl<K: Eq + Hash, V: HeapSizeOf> MemoryLruCache<K, V> {
|
||||
impl<K: Eq + Hash, V: MallocSizeOf> MemoryLruCache<K, V> {
|
||||
/// Create a new cache with a maximum size in bytes.
|
||||
pub fn new(max_size: usize) -> Self {
|
||||
MemoryLruCache {
|
||||
|
||||
Reference in New Issue
Block a user