Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions src/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ mod tests {
let token = create_token(
perms_expected.clone(),
key.private_key(),
Duration::try_hours(1).expect("Infallible"),
Duration::hours(1),
)
.unwrap();
let perms = verify_token(&token, key.private_key()).unwrap();
Expand All @@ -98,7 +98,7 @@ mod tests {
let token = create_token(
perms_expected.clone(),
key.private_key(),
-Duration::try_hours(1).expect("Infallible"),
-Duration::hours(1),
)
.unwrap();
assert!(verify_token(&token, key.private_key()).is_err());
Expand All @@ -108,7 +108,7 @@ mod tests {
let token = create_token(
perms_expected.clone(),
key.private_key(),
-Duration::try_seconds(10).expect("Infallible"),
-Duration::seconds(10),
)
.unwrap();
let perms = verify_token(&token, key.private_key()).unwrap();
Expand Down Expand Up @@ -138,7 +138,7 @@ mod tests {
let token = create_token(
perms_expected.clone(),
key.private_key(),
-Duration::try_hours(1).expect("Infallible"),
-Duration::hours(1),
)
.unwrap();
let perms = verify_token(&token, key.private_key()).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/chain/store/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl<DB: Blockstore> ChainIndex<DB> {
SizeTrackingLruCache::new_with_metrics(
"tipset_by_height".into(),
// 20480 * 900 = 18432000 which is sufficient for mainnet
20480.try_into().expect("infallible"),
nonzero!(20480_usize),
)
});

Expand Down
13 changes: 4 additions & 9 deletions src/chain_sync/network_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use crate::{
};
use anyhow::Context as _;
use fvm_ipld_blockstore::Blockstore;
use nonzero_ext::nonzero;
use parking_lot::Mutex;
use std::future::Future;
use tokio::sync::Semaphore;
Expand Down Expand Up @@ -152,13 +153,7 @@ where
ts: &Tipset,
) -> Result<FullTipset, String> {
let mut bundles: Vec<TipsetBundle> = self
.handle_chain_exchange_request(
peer_id,
ts.key(),
NonZeroU64::new(1).expect("Infallible"),
MESSAGES,
|_| true,
)
.handle_chain_exchange_request(peer_id, ts.key(), nonzero!(1_u64), MESSAGES, |_| true)
.await?;

if bundles.len() != 1 {
Expand All @@ -184,7 +179,7 @@ where
.handle_chain_exchange_request(
peer_id,
tsk,
NonZeroU64::new(1).expect("Infallible"),
nonzero!(1_u64),
HEADERS | MESSAGES,
|_| true,
)
Expand All @@ -207,7 +202,7 @@ where
self.handle_chain_exchange_request(
peer_id,
tsk,
NonZeroU64::new(16).expect("Infallible"),
nonzero!(16_u64),
HEADERS | MESSAGES,
|_| true,
)
Expand Down
11 changes: 5 additions & 6 deletions src/rpc/methods/f3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ use enumflags2::BitFlags;
use fvm_ipld_blockstore::Blockstore;
use jsonrpsee::core::{client::ClientT as _, params::ArrayParams};
use libp2p::PeerId;
use nonzero_ext::nonzero;
use num::Signed as _;
use parking_lot::RwLock;
use std::num::NonZeroUsize;
use std::{
borrow::Cow,
fmt::Display,
Expand Down Expand Up @@ -166,12 +168,9 @@ impl GetPowerTable {
ts: &Tipset,
) -> anyhow::Result<Vec<F3PowerEntry>> {
// The RAM overhead on mainnet is ~14MiB
const BLOCKSTORE_CACHE_CAP: usize = 65536;
const BLOCKSTORE_CACHE_CAP: NonZeroUsize = nonzero!(65536_usize);
static BLOCKSTORE_CACHE: LazyLock<LruBlockstoreReadCache> = LazyLock::new(|| {
LruBlockstoreReadCache::new_with_metrics(
"get_powertable".into(),
BLOCKSTORE_CACHE_CAP.try_into().expect("Infallible"),
)
LruBlockstoreReadCache::new_with_metrics("get_powertable".into(), BLOCKSTORE_CACHE_CAP)
});
let db = BlockstoreWithReadCache::new(
ctx.store_owned(),
Expand Down Expand Up @@ -531,7 +530,7 @@ impl RpcMethod<1> for Finalize {
Some(ts) => ts,
None => ctx
.sync_network_context
.chain_exchange_headers(None, &tsk, 1.try_into().expect("Infallible"))
.chain_exchange_headers(None, &tsk, nonzero!(1_u64))
.await?
.first()
.cloned()
Expand Down
Loading