mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: use Display when formatting addresses and hashes (#6245)
This commit is contained in:
@ -57,7 +57,7 @@ impl fmt::Display for Head {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"Head Block:\n Number: {}\n Hash: {:?}\n Difficulty: {:?}\n Total Difficulty: {:?}\n Timestamp: {}",
|
||||
"Head Block:\n Number: {}\n Hash: {}\n Difficulty: {:?}\n Total Difficulty: {:?}\n Timestamp: {}",
|
||||
self.number, self.hash, self.difficulty, self.total_difficulty, self.timestamp
|
||||
)
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ impl std::fmt::Display for InsertBlockErrorData {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"Failed to insert block (hash={:?}, number={}, parent_hash={:?}): {}",
|
||||
"Failed to insert block (hash={}, number={}, parent_hash={}): {}",
|
||||
self.block.hash, self.block.number, self.block.parent_hash, self.kind
|
||||
)
|
||||
}
|
||||
|
||||
@ -683,7 +683,7 @@ where
|
||||
debug_assert!(
|
||||
self.peers.contains_key(&peer_id),
|
||||
"a dead peer has been returned as idle by `@pop_any_idle_peer`, broken invariant `@peers` and `@transaction_fetcher`,
|
||||
`%peer_id`: {:?},
|
||||
`%peer_id`: {},
|
||||
`@peers`: {:?},
|
||||
`@transaction_fetcher`: {:?}",
|
||||
peer_id, self.peers, self.transaction_fetcher
|
||||
|
||||
@ -55,7 +55,7 @@ where
|
||||
let peers = peers
|
||||
.into_iter()
|
||||
.map(|peer| PeerInfo {
|
||||
id: Some(format!("{:?}", peer.remote_id)),
|
||||
id: Some(peer.remote_id.to_string()),
|
||||
name: peer.client_version.to_string(),
|
||||
caps: peer.capabilities.capabilities().iter().map(|cap| cap.to_string()).collect(),
|
||||
network: PeerNetworkInfo {
|
||||
@ -68,7 +68,7 @@ where
|
||||
protocols: PeerProtocolsInfo {
|
||||
eth: Some(PeerEthProtocolInfo {
|
||||
difficulty: Some(peer.status.total_difficulty),
|
||||
head: format!("{:?}", peer.status.blockhash),
|
||||
head: peer.status.blockhash.to_string(),
|
||||
version: peer.status.version as u32,
|
||||
}),
|
||||
pip: None,
|
||||
|
||||
@ -211,7 +211,7 @@ impl DiskFileBlobStoreInner {
|
||||
/// Returns the path to the blob file for the given transaction hash.
|
||||
#[inline]
|
||||
fn blob_disk_file(&self, tx: B256) -> PathBuf {
|
||||
self.blob_dir.join(format!("{:x}", tx))
|
||||
self.blob_dir.join(format!("{tx:x}"))
|
||||
}
|
||||
|
||||
/// Retries the blob data for the given transaction hash.
|
||||
|
||||
@ -355,13 +355,12 @@ impl<T: PoolTransaction + Clone> Clone for ValidPoolTransaction<T> {
|
||||
}
|
||||
|
||||
impl<T: PoolTransaction> fmt::Debug for ValidPoolTransaction<T> {
|
||||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(fmt, "Transaction {{ ")?;
|
||||
write!(fmt, "hash: {:?}, ", &self.transaction.hash())?;
|
||||
write!(fmt, "provides: {:?}, ", &self.transaction_id)?;
|
||||
write!(fmt, "raw tx: {:?}", &self.transaction)?;
|
||||
write!(fmt, "}}")?;
|
||||
Ok(())
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
f.debug_struct("ValidPoolTransaction")
|
||||
.field("hash", self.transaction.hash())
|
||||
.field("provides", &self.transaction_id)
|
||||
.field("raw_tx", &self.transaction)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -73,7 +73,7 @@ impl RethNodeCommandConfig for RethCliTxpoolExt {
|
||||
// Waiting for new transactions
|
||||
while let Some(event) = pending_transactions.next().await {
|
||||
let tx = event.transaction;
|
||||
println!("Transaction received: {:?}", tx);
|
||||
println!("Transaction received: {tx:?}");
|
||||
|
||||
if let Some(tx_recipient_address) = tx.to() {
|
||||
if recipients.is_empty() || recipients.contains(&tx_recipient_address) {
|
||||
@ -83,11 +83,8 @@ impl RethNodeCommandConfig for RethCliTxpoolExt {
|
||||
let tracerequest =
|
||||
TraceCallRequest::new(callrequest).with_trace_type(TraceType::Trace);
|
||||
if let Ok(trace_result) = traceapi.trace_call(tracerequest).await {
|
||||
println!(
|
||||
"trace result for transaction : {:?} is {:?}",
|
||||
tx.hash(),
|
||||
trace_result
|
||||
);
|
||||
let hash = tx.hash();
|
||||
println!("trace result for transaction {hash}: {trace_result:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -210,7 +210,7 @@ impl Account {
|
||||
/// In case of a mismatch, `Err(Error::Assertion)` is returned.
|
||||
pub fn assert_db(&self, address: Address, tx: &impl DbTx) -> Result<(), Error> {
|
||||
let account = tx.get::<tables::PlainAccountState>(address)?.ok_or_else(|| {
|
||||
Error::Assertion(format!("Expected account ({address:?}) is missing from DB: {self:?}"))
|
||||
Error::Assertion(format!("Expected account ({address}) is missing from DB: {self:?}"))
|
||||
})?;
|
||||
|
||||
assert_equal(self.balance.into(), account.balance, "Balance does not match")?;
|
||||
|
||||
Reference in New Issue
Block a user