Update some dependencies to prune duplicated crates with different version (#12560)

* sc-client-babe/sp-arithmetic-fuzzer: update num-bigint and num-rational to v0.4

* update lru 0.7.5 ==> v0.8.1

* pallet-example-offchain-worker: update lite-json v0.1.3 ==> v0.2.0

* update hyper 0.14.16 ==> 0.14.20, num-fromat 0.4.0 ==> 0.4.3

* pallet-mmr: update ckb-merkle-mountain-range v0.3.2 ==> v0.5.2

* update handlebars v4.2.2 ==> v4.3.5

* `runtime_cache_size` must always be at least 1

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* default cache size with .min(1)

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* update hyper 0.14.20 ==> 0.14.22

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* update lru 0.8.0 ==> 0.8.1

Signed-off-by: koushiro <koushiro.cqx@gmail.com>

* Apply suggestions from code review

* Apply suggestions from code review

* Fix Cargo.lock

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
Co-authored-by: Bastian Köcher <git@kchr.de>
Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
Qinxuan Chen
2022-11-09 19:46:00 +08:00
committed by GitHub
parent 657d99202c
commit ad6630ed71
22 changed files with 191 additions and 269 deletions
@@ -21,6 +21,7 @@
use lru::LruCache;
use parking_lot::RwLock;
use sp_runtime::traits::{Block as BlockT, Header, NumberFor, One};
use std::num::NonZeroUsize;
/// Set to the expected max difference between `best` and `finalized` blocks at sync.
const LRU_CACHE_SIZE: usize = 5_000;
@@ -239,14 +240,15 @@ pub struct HeaderMetadataCache<Block: BlockT> {
impl<Block: BlockT> HeaderMetadataCache<Block> {
/// Creates a new LRU header metadata cache with `capacity`.
pub fn new(capacity: usize) -> Self {
pub fn new(capacity: NonZeroUsize) -> Self {
HeaderMetadataCache { cache: RwLock::new(LruCache::new(capacity)) }
}
}
impl<Block: BlockT> Default for HeaderMetadataCache<Block> {
fn default() -> Self {
HeaderMetadataCache { cache: RwLock::new(LruCache::new(LRU_CACHE_SIZE)) }
let cap = NonZeroUsize::new(LRU_CACHE_SIZE).expect("cache capacity is not zero");
HeaderMetadataCache { cache: RwLock::new(LruCache::new(cap)) }
}
}