fix clippy warnings

This commit is contained in:
Christian Kamm 2022-06-21 13:10:22 +02:00
parent 5dd186ac13
commit aeb94642ce
5 changed files with 9 additions and 9 deletions

View File

@ -271,11 +271,11 @@ impl ChainData {
pub fn account<'a>(&'a self, pubkey: &Pubkey) -> anyhow::Result<&'a AccountSharedData> {
self.accounts
.get(pubkey)
.ok_or(anyhow::anyhow!("account {} not found", pubkey))?
.ok_or_else(|| anyhow::anyhow!("account {} not found", pubkey))?
.iter()
.rev()
.find(|w| self.is_account_write_live(w))
.ok_or(anyhow::anyhow!("account {} has no live data", pubkey))
.ok_or_else(|| anyhow::anyhow!("account {} has no live data", pubkey))
.map(|w| &w.account)
}
}

View File

@ -87,7 +87,7 @@ impl Metrics {
let mut registry = self.registry.write().unwrap();
let value = registry
.entry(name)
.or_insert(Value::U64(Arc::new(atomic::AtomicU64::new(0))));
.or_insert_with(|| Value::U64(Arc::new(atomic::AtomicU64::new(0))));
MetricU64 {
value: match value {
Value::U64(v) => v.clone(),
@ -100,7 +100,7 @@ impl Metrics {
let mut registry = self.registry.write().unwrap();
let value = registry
.entry(name)
.or_insert(Value::I64(Arc::new(atomic::AtomicI64::new(0))));
.or_insert_with(|| Value::I64(Arc::new(atomic::AtomicI64::new(0))));
MetricI64 {
value: match value {
Value::I64(v) => v.clone(),
@ -113,7 +113,7 @@ impl Metrics {
let mut registry = self.registry.write().unwrap();
let value = registry
.entry(name)
.or_insert(Value::String(Arc::new(Mutex::new(String::new()))));
.or_insert_with(|| Value::String(Arc::new(Mutex::new(String::new()))));
MetricString {
value: match value {
Value::String(v) => v.clone(),

View File

@ -44,7 +44,7 @@ impl AccountSnapshot {
account: a
.account
.decode()
.ok_or(anyhow::anyhow!("could not decode account"))?,
.ok_or_else(|| anyhow::anyhow!("could not decode account"))?,
});
}
Ok(())
@ -63,7 +63,7 @@ impl AccountSnapshot {
pubkey,
account: ui_account
.decode()
.ok_or(anyhow::anyhow!("could not decode account"))?,
.ok_or_else(|| anyhow::anyhow!("could not decode account"))?,
});
}
}

View File

@ -30,7 +30,7 @@ impl AccountUpdate {
.value
.account
.decode()
.ok_or(anyhow::anyhow!("could not decode account"))?;
.ok_or_else(|| anyhow::anyhow!("could not decode account"))?;
Ok(AccountUpdate {
pubkey,
slot: rpc.context.slot,