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
2 changes: 1 addition & 1 deletion common/client-core/src/client/topology_control/accessor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl TopologyAccessor {
.map(|p| p.topology.clone())
}

pub async fn current_route_provider(&self) -> Option<RwLockReadGuard<NymRouteProvider>> {
pub async fn current_route_provider(&self) -> Option<RwLockReadGuard<'_, NymRouteProvider>> {
let provider = self.inner.topology.read().await;
if provider.topology.is_empty() {
None
Expand Down
2 changes: 1 addition & 1 deletion common/client-core/src/init/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async fn connect(endpoint: &str) -> Result<WsConn, ClientCoreError> {
JSWebsocket::new(endpoint).map_err(|_| ClientCoreError::GatewayJsConnectionFailure)
}

async fn measure_latency<G>(gateway: &G) -> Result<GatewayWithLatency<G>, ClientCoreError>
async fn measure_latency<G>(gateway: &G) -> Result<GatewayWithLatency<'_, G>, ClientCoreError>
where
G: ConnectableGateway,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ pub async fn delegate_to_multiple_mixnodes(args: Args, client: SigningClient) {
let node_id = row.node_id.clone().parse::<u32>().unwrap();
let coins: Vec<Coin> = vec![];
undelegation_msgs.push((ExecuteMsg::Undelegate { node_id }, coins));
undelegation_table.add_row(&[row.node_id.clone()]);
undelegation_table.add_row(std::slice::from_ref(&row.node_id));

if row.amount.amount > 0 {
delegation_msgs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl<C> ContractTesterBuilder<C> {
*self.app.api()
}

pub fn querier(&self) -> QuerierWrapper {
pub fn querier(&self) -> QuerierWrapper<'_> {
self.app.wrap()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub trait NodeBond {

fn is_unbonding(&self) -> bool;

fn identity(&self) -> IdentityKeyRef;
fn identity(&self) -> IdentityKeyRef<'_>;

fn original_pledge(&self) -> &Coin;

Expand Down Expand Up @@ -125,7 +125,7 @@ impl NodeBond for MixNodeBond {
self.is_unbonding
}

fn identity(&self) -> IdentityKeyRef {
fn identity(&self) -> IdentityKeyRef<'_> {
self.identity()
}

Expand Down Expand Up @@ -178,7 +178,7 @@ impl NodeBond for NymNodeBond {
self.is_unbonding
}

fn identity(&self) -> IdentityKeyRef {
fn identity(&self) -> IdentityKeyRef<'_> {
self.identity()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl<'a> PrimaryKey<'a> for Role {
type Suffix = <u8 as PrimaryKey<'a>>::Suffix;
type SuperSuffix = <u8 as PrimaryKey<'a>>::SuperSuffix;

fn key(&self) -> Vec<Key> {
fn key(&self) -> Vec<Key<'_>> {
// I'm not sure why it wasn't possible to delegate the call to
// `(*self as u8).key()` directly...
// I guess because of the `Key::Ref(&'a [u8])` variant?
Expand Down
2 changes: 1 addition & 1 deletion common/credential-storage/src/backends/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl SqliteEcashTicketbookManager {
Ok(())
}

pub(crate) async fn begin_storage_tx(&self) -> Result<Transaction<Sqlite>, sqlx::Error> {
pub(crate) async fn begin_storage_tx(&self) -> Result<Transaction<'_, Sqlite>, sqlx::Error> {
self.connection_pool.begin().await
}

Expand Down
4 changes: 2 additions & 2 deletions common/credential-verification/src/ecash/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl traits::EcashManager for EcashManager {
async fn verification_key(
&self,
epoch_id: EpochId,
) -> Result<RwLockReadGuard<VerificationKeyAuth>, EcashTicketError> {
) -> Result<RwLockReadGuard<'_, VerificationKeyAuth>, EcashTicketError> {
self.shared_state.verification_key(epoch_id).await
}

Expand Down Expand Up @@ -231,7 +231,7 @@ impl traits::EcashManager for MockEcashManager {
async fn verification_key(
&self,
_epoch_id: EpochId,
) -> Result<RwLockReadGuard<VerificationKeyAuth>, EcashTicketError> {
) -> Result<RwLockReadGuard<'_, VerificationKeyAuth>, EcashTicketError> {
Ok(self.verfication_key.read().await)
}

Expand Down
10 changes: 5 additions & 5 deletions common/credential-verification/src/ecash/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl SharedState {
async fn set_epoch_data(
&self,
epoch_id: EpochId,
) -> Result<RwLockWriteGuard<BTreeMap<EpochId, EpochState>>, EcashTicketError> {
) -> Result<RwLockWriteGuard<'_, BTreeMap<EpochId, EpochState>>, EcashTicketError> {
let Some(threshold) = self.threshold(epoch_id).await? else {
return Err(EcashTicketError::DKGThresholdUnavailable { epoch_id });
};
Expand Down Expand Up @@ -186,7 +186,7 @@ impl SharedState {
pub(crate) async fn api_clients(
&self,
epoch_id: EpochId,
) -> Result<RwLockReadGuard<Vec<EcashApiClient>>, EcashTicketError> {
) -> Result<RwLockReadGuard<'_, Vec<EcashApiClient>>, EcashTicketError> {
let guard = self.epoch_data.read().await;

// the key was already in the map
Expand All @@ -212,7 +212,7 @@ impl SharedState {
pub(crate) async fn verification_key(
&self,
epoch_id: EpochId,
) -> Result<RwLockReadGuard<VerificationKeyAuth>, EcashTicketError> {
) -> Result<RwLockReadGuard<'_, VerificationKeyAuth>, EcashTicketError> {
let guard = self.epoch_data.read().await;

// the key was already in the map
Expand All @@ -235,11 +235,11 @@ impl SharedState {
}))
}

pub(crate) async fn start_tx(&self) -> RwLockWriteGuard<DirectSigningHttpRpcNyxdClient> {
pub(crate) async fn start_tx(&self) -> RwLockWriteGuard<'_, DirectSigningHttpRpcNyxdClient> {
self.nyxd_client.write().await
}

pub(crate) async fn start_query(&self) -> RwLockReadGuard<DirectSigningHttpRpcNyxdClient> {
pub(crate) async fn start_query(&self) -> RwLockReadGuard<'_, DirectSigningHttpRpcNyxdClient> {
self.nyxd_client.read().await
}

Expand Down
2 changes: 1 addition & 1 deletion common/credential-verification/src/ecash/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub trait EcashManager {
async fn verification_key(
&self,
epoch_id: EpochId,
) -> Result<RwLockReadGuard<VerificationKeyAuth>, EcashTicketError>;
) -> Result<RwLockReadGuard<'_, VerificationKeyAuth>, EcashTicketError>;
fn storage(&self) -> Box<dyn BandwidthGatewayStorage + Send + Sync>;
async fn check_payment(
&self,
Expand Down
2 changes: 1 addition & 1 deletion nym-api/src/ecash/comm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl QueryCommunicationChannel {
}
}

async fn update_epoch_cache(&self) -> Result<RwLockWriteGuard<CachedEpoch>> {
async fn update_epoch_cache(&self) -> Result<RwLockWriteGuard<'_, CachedEpoch>> {
let mut guard = self.cached_epoch.write().await;

let epoch = ecash::client::Client::get_current_epoch(&self.nyxd_client).await?;
Expand Down
2 changes: 1 addition & 1 deletion nym-api/src/ecash/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ where
&self,
key: K,
f: F,
) -> Result<RwLockReadGuard<V>, EcashError>
) -> Result<RwLockReadGuard<'_, V>, EcashError>
where
F: FnOnce() -> U,
U: Future<Output = Result<V, EcashError>>,
Expand Down
6 changes: 3 additions & 3 deletions nym-api/src/ecash/keys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ impl KeyPair {
}
}

pub async fn keys(&self) -> Result<RwLockReadGuard<KeyPairWithEpoch>, EcashError> {
pub async fn keys(&self) -> Result<RwLockReadGuard<'_, KeyPairWithEpoch>, EcashError> {
let keypair_guard = self.get().await.ok_or(EcashError::KeyPairNotDerivedYet)?;
RwLockReadGuard::try_map(keypair_guard, |keypair| keypair.as_ref())
.map_err(|_| EcashError::KeyPairNotDerivedYet)
}

pub async fn signing_key(&self) -> Result<RwLockReadGuard<SecretKeyAuth>, EcashError> {
pub async fn signing_key(&self) -> Result<RwLockReadGuard<'_, SecretKeyAuth>, EcashError> {
let keypair_guard = self.get().await.ok_or(EcashError::KeyPairNotDerivedYet)?;

RwLockReadGuard::try_map(keypair_guard, |keypair| {
Expand All @@ -80,7 +80,7 @@ impl KeyPair {
.map_err(|_| EcashError::KeyPairNotDerivedYet)
}

pub async fn verification_key(&self) -> Option<RwLockReadGuard<VerificationKeyAuth>> {
pub async fn verification_key(&self) -> Option<RwLockReadGuard<'_, VerificationKeyAuth>> {
RwLockReadGuard::try_map(self.get().await?, |maybe_keys| {
maybe_keys.as_ref().map(|k| k.keys.verification_key_ref())
})
Expand Down
18 changes: 9 additions & 9 deletions nym-api/src/ecash/state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,21 +198,21 @@ impl EcashState {
Ok(())
}

pub(crate) async fn ecash_signing_key(&self) -> Result<RwLockReadGuard<SecretKeyAuth>> {
pub(crate) async fn ecash_signing_key(&self) -> Result<RwLockReadGuard<'_, SecretKeyAuth>> {
self.local.ecash_keypair.signing_key().await
}

#[allow(dead_code)]
pub(crate) async fn current_master_verification_key(
&self,
) -> Result<RwLockReadGuard<VerificationKeyAuth>> {
) -> Result<RwLockReadGuard<'_, VerificationKeyAuth>> {
self.master_verification_key(None).await
}

pub(crate) async fn master_verification_key(
&self,
epoch_id: Option<EpochId>,
) -> Result<RwLockReadGuard<VerificationKeyAuth>> {
) -> Result<RwLockReadGuard<'_, VerificationKeyAuth>> {
let epoch_id = match epoch_id {
Some(id) => id,
None => self.aux.current_epoch().await?,
Expand Down Expand Up @@ -258,7 +258,7 @@ impl EcashState {
pub(crate) async fn master_coin_index_signatures(
&self,
epoch_id: Option<EpochId>,
) -> Result<RwLockReadGuard<IssuedCoinIndicesSignatures>> {
) -> Result<RwLockReadGuard<'_, IssuedCoinIndicesSignatures>> {
let epoch_id = match epoch_id {
Some(id) => id,
None => self.aux.current_epoch().await?,
Expand Down Expand Up @@ -344,7 +344,7 @@ impl EcashState {
pub(crate) async fn partial_coin_index_signatures(
&self,
epoch_id: Option<EpochId>,
) -> Result<RwLockReadGuard<IssuedCoinIndicesSignatures>> {
) -> Result<RwLockReadGuard<'_, IssuedCoinIndicesSignatures>> {
let epoch_id = match epoch_id {
Some(id) => id,
None => self.aux.current_epoch().await?,
Expand Down Expand Up @@ -401,7 +401,7 @@ impl EcashState {
pub(crate) async fn master_expiration_date_signatures(
&self,
expiration_date: Date,
) -> Result<RwLockReadGuard<IssuedExpirationDateSignatures>> {
) -> Result<RwLockReadGuard<'_, IssuedExpirationDateSignatures>> {
self.global
.expiration_date_signatures
.get_or_init(expiration_date, || async {
Expand Down Expand Up @@ -480,7 +480,7 @@ impl EcashState {
pub(crate) async fn partial_expiration_date_signatures(
&self,
expiration_date: Date,
) -> Result<RwLockReadGuard<IssuedExpirationDateSignatures>> {
) -> Result<RwLockReadGuard<'_, IssuedExpirationDateSignatures>> {
self.local
.partial_expiration_date_signatures
.get_or_init(expiration_date, || async {
Expand Down Expand Up @@ -721,7 +721,7 @@ impl EcashState {
async fn get_updated_merkle_read(
&self,
expiration_date: Date,
) -> Result<RwLockReadGuard<DailyMerkleTree>> {
) -> Result<RwLockReadGuard<'_, DailyMerkleTree>> {
let write_guard = self.get_updated_full_write(expiration_date).await?;

// SAFETY: the entry was either not empty or we just inserted data in there, whilst never dropping the lock
Expand All @@ -735,7 +735,7 @@ impl EcashState {
async fn get_updated_full_write(
&self,
expiration_date: Date,
) -> Result<RwLockWriteGuard<HashMap<Date, DailyMerkleTree>>> {
) -> Result<RwLockWriteGuard<'_, HashMap<Date, DailyMerkleTree>>> {
let mut write_guard = self.local.issued_merkle_trees.write().await;

// double check if it's still empty in case another task has already grabbed the write lock and performed the update
Expand Down
2 changes: 1 addition & 1 deletion nym-api/src/epoch_operations/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub(super) fn stake_to_f64(stake: Decimal) -> f64 {

impl EpochAdvancer {
fn load_performance(
status_cache: &Option<RwLockReadGuard<Cache<HashMap<NodeId, NodeAnnotation>>>>,
status_cache: &Option<RwLockReadGuard<'_, Cache<HashMap<NodeId, NodeAnnotation>>>>,
node_id: NodeId,
) -> NodeWithPerformance {
let Some(status_cache) = status_cache.as_ref() else {
Expand Down
8 changes: 4 additions & 4 deletions nym-api/src/mixnet_contract_cache/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl MixnetContractCache {

pub async fn all_cached_legacy_mixnodes(
&self,
) -> Option<RwLockReadGuard<Vec<LegacyMixNodeDetailsWithLayer>>> {
) -> Option<RwLockReadGuard<'_, Vec<LegacyMixNodeDetailsWithLayer>>> {
self.get(|c| &c.legacy_mixnodes).await.ok()
}

Expand All @@ -84,11 +84,11 @@ impl MixnetContractCache {

pub async fn all_cached_legacy_gateways(
&self,
) -> Option<RwLockReadGuard<Vec<LegacyGatewayBondWithId>>> {
) -> Option<RwLockReadGuard<'_, Vec<LegacyGatewayBondWithId>>> {
self.get(|c| &c.legacy_gateways).await.ok()
}

pub async fn all_cached_nym_nodes(&self) -> Option<RwLockReadGuard<Vec<NymNodeDetails>>> {
pub async fn all_cached_nym_nodes(&self) -> Option<RwLockReadGuard<'_, Vec<NymNodeDetails>>> {
self.get(|c| &c.nym_nodes).await.ok()
}

Expand Down Expand Up @@ -125,7 +125,7 @@ impl MixnetContractCache {
Ok(Cache::as_mapped(&cache, |c| c.rewarded_set.clone()))
}

pub async fn rewarded_set(&self) -> Option<RwLockReadGuard<CachedEpochRewardedSet>> {
pub async fn rewarded_set(&self) -> Option<RwLockReadGuard<'_, CachedEpochRewardedSet>> {
self.get(|c| &c.rewarded_set).await.ok()
}

Expand Down
6 changes: 3 additions & 3 deletions nym-api/src/node_status_api/cache/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl NodeStatusCache {

pub(crate) async fn node_annotations(
&self,
) -> Option<RwLockReadGuard<Cache<HashMap<NodeId, NodeAnnotation>>>> {
) -> Option<RwLockReadGuard<'_, Cache<HashMap<NodeId, NodeAnnotation>>>> {
self.get(|c| &c.node_annotations).await
}

Expand All @@ -127,7 +127,7 @@ impl NodeStatusCache {

pub(crate) async fn annotated_legacy_mixnodes(
&self,
) -> Option<RwLockReadGuard<Cache<HashMap<NodeId, MixNodeBondAnnotated>>>> {
) -> Option<RwLockReadGuard<'_, Cache<HashMap<NodeId, MixNodeBondAnnotated>>>> {
self.get(|c| &c.mixnodes_annotated).await
}

Expand All @@ -150,7 +150,7 @@ impl NodeStatusCache {

pub(crate) async fn annotated_legacy_gateways(
&self,
) -> Option<RwLockReadGuard<Cache<HashMap<NodeId, GatewayBondAnnotated>>>> {
) -> Option<RwLockReadGuard<'_, Cache<HashMap<NodeId, GatewayBondAnnotated>>>> {
self.get(|c| &c.gateways_annotated).await
}

Expand Down
20 changes: 1 addition & 19 deletions nym-api/src/node_status_api/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,13 @@ use crate::{MixnetContractCache, NodeStatusCache};
use nym_api_requests::models::{
ComputeRewardEstParam, GatewayBondAnnotated, GatewayCoreStatusResponse,
GatewayStatusReportResponse, GatewayUptimeHistoryResponse, GatewayUptimeResponse,
MixNodeBondAnnotated, MixnodeCoreStatusResponse, MixnodeStatus, MixnodeStatusReportResponse,
MixNodeBondAnnotated, MixnodeCoreStatusResponse, MixnodeStatusReportResponse,
MixnodeStatusResponse, MixnodeUptimeHistoryResponse, RewardEstimationResponse,
StakeSaturationResponse, UptimeResponse,
};
use nym_mixnet_contract_common::rewarding::RewardEstimate;
use nym_mixnet_contract_common::NodeId;

pub(crate) enum RewardedSetStatus {
Active,
Standby,
Inactive,
}

impl From<MixnodeStatus> for RewardedSetStatus {
fn from(value: MixnodeStatus) -> Self {
match value {
MixnodeStatus::Active => RewardedSetStatus::Active,
MixnodeStatus::Standby => RewardedSetStatus::Standby,
// for all intents and purposes, missing node is treated as inactive for rewarding (since it wouldn't get anything
MixnodeStatus::Inactive => RewardedSetStatus::Inactive,
MixnodeStatus::NotFound => RewardedSetStatus::Inactive,
}
}
}

async fn gateway_identity_to_node_id(
cache: &NodeStatusCache,
identity: &str,
Expand Down
Loading
Loading