Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
runtime_cache_size must always be at least 1
Signed-off-by: koushiro <[email protected]>
  • Loading branch information
koushiro committed Oct 27, 2022
commit 54ca479d9aff188574b1bc6ee9e53a51d0b1ac2e
2 changes: 1 addition & 1 deletion client/cli/src/commands/run_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ pub struct RunCmd {
pub max_runtime_instances: Option<usize>,

/// Maximum number of different runtimes that can be cached.
#[arg(long, default_value_t = 2)]
#[arg(long, default_value_t = 2, value_parser = clap::value_parser!(u8).range(1..))]
pub runtime_cache_size: u8,

/// Run a temporary node.
Expand Down
2 changes: 1 addition & 1 deletion client/executor/src/wasm_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl RuntimeCache {
/// for caching.
///
/// `runtime_cache_size` specifies the number of different runtimes versions preserved in an
/// in-memory cache.
/// in-memory cache, must always be at least 1.
pub fn new(
max_runtime_instances: usize,
cache_path: Option<PathBuf>,
Expand Down
5 changes: 3 additions & 2 deletions client/network/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use libp2p::{
Multiaddr, PeerId,
};
use log::{debug, error, info, log, trace, warn, Level};
use lru::LruCache;
use message::{generic::Message as GenericMessage, Message};
use notifications::{Notifications, NotificationsOut};
use prometheus_endpoint::{register, Gauge, GaugeVec, Opts, PrometheusError, Registry, U64};
Expand Down Expand Up @@ -200,7 +201,7 @@ pub struct Protocol<B: BlockT, Client> {
/// The `PeerId`'s of all boot nodes.
boot_node_ids: HashSet<PeerId>,
/// A cache for the data that was associated to a block announcement.
block_announce_data_cache: lru::LruCache<B::Hash, Vec<u8>>,
block_announce_data_cache: LruCache<B::Hash, Vec<u8>>,
}

#[derive(Debug)]
Expand Down Expand Up @@ -361,7 +362,7 @@ where
network_config.default_peers_set.out_peers as usize,
)
.expect("cache capacity is not zero");
let block_announce_data_cache = lru::LruCache::new(cache_capacity);
let block_announce_data_cache = LruCache::new(cache_capacity);

let protocol = Self {
tick_timeout: Box::pin(interval(TICK_TIMEOUT)),
Expand Down
5 changes: 2 additions & 3 deletions primitives/blockchain/src/header_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,8 @@ 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 {
let non_zero_cap = NonZeroUsize::new(capacity).expect("capacity is not zero");
HeaderMetadataCache { cache: RwLock::new(LruCache::new(non_zero_cap)) }
pub fn new(capacity: NonZeroUsize) -> Self {
HeaderMetadataCache { cache: RwLock::new(LruCache::new(capacity)) }
}
}

Expand Down