mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
Bump lru from 0.7.8 to 0.8.0 (#6060)
* Bump lru from 0.7.8 to 0.8.0 Bumps [lru](https://github.com/jeromefroe/lru-rs) from 0.7.8 to 0.8.0. - [Release notes](https://github.com/jeromefroe/lru-rs/releases) - [Changelog](https://github.com/jeromefroe/lru-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/jeromefroe/lru-rs/compare/0.7.8...0.8.0) --- updated-dependencies: - dependency-name: lru dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * Change `LruCache` paramerter to `NonZeroUsize` * Change type of `session_cache_lru_size` to `NonZeroUsize` * Add expects instead of unwrap Co-authored-by: Bastian Köcher <info@kchr.de> * Use match to get rid of expects Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Sebastian Kunert <skunert49@gmail.com> Co-authored-by: Bastian Köcher <info@kchr.de>
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Convenient interface to runtime information.
|
||||
|
||||
use std::cmp::max;
|
||||
use std::num::NonZeroUsize;
|
||||
|
||||
use lru::LruCache;
|
||||
|
||||
@@ -52,7 +52,7 @@ pub struct Config {
|
||||
pub keystore: Option<SyncCryptoStorePtr>,
|
||||
|
||||
/// How many sessions should we keep in the cache?
|
||||
pub session_cache_lru_size: usize,
|
||||
pub session_cache_lru_size: NonZeroUsize,
|
||||
}
|
||||
|
||||
/// Caching of session info.
|
||||
@@ -95,7 +95,7 @@ impl Default for Config {
|
||||
Self {
|
||||
keystore: None,
|
||||
// Usually we need to cache the current and the last session.
|
||||
session_cache_lru_size: 2,
|
||||
session_cache_lru_size: NonZeroUsize::new(2).expect("2 is larger than 0; qed"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,10 @@ impl RuntimeInfo {
|
||||
/// Create with more elaborate configuration options.
|
||||
pub fn new_with_config(cfg: Config) -> Self {
|
||||
Self {
|
||||
session_index_cache: LruCache::new(max(10, cfg.session_cache_lru_size)),
|
||||
session_index_cache: LruCache::new(
|
||||
cfg.session_cache_lru_size
|
||||
.max(NonZeroUsize::new(10).expect("10 is larger than 0; qed")),
|
||||
),
|
||||
session_info_cache: LruCache::new(cfg.session_cache_lru_size),
|
||||
keystore: cfg.keystore,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user