mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
feat: convert hash field to OnceLock<TxHash> on TransactionSigned (#12596)
Co-authored-by: joshieDo <93316087+joshieDo@users.noreply.github.com>
This commit is contained in:
@ -92,16 +92,17 @@ fn txs_provider_example<T: TransactionsProvider>(provider: T) -> eyre::Result<()
|
||||
|
||||
// Can query the tx by hash
|
||||
let tx_by_hash =
|
||||
provider.transaction_by_hash(tx.hash)?.ok_or(eyre::eyre!("txhash not found"))?;
|
||||
provider.transaction_by_hash(tx.hash())?.ok_or(eyre::eyre!("txhash not found"))?;
|
||||
assert_eq!(tx, tx_by_hash);
|
||||
|
||||
// Can query the tx by hash with info about the block it was included in
|
||||
let (tx, meta) =
|
||||
provider.transaction_by_hash_with_meta(tx.hash)?.ok_or(eyre::eyre!("txhash not found"))?;
|
||||
assert_eq!(tx.hash, meta.tx_hash);
|
||||
let (tx, meta) = provider
|
||||
.transaction_by_hash_with_meta(tx.hash())?
|
||||
.ok_or(eyre::eyre!("txhash not found"))?;
|
||||
assert_eq!(tx.hash(), meta.tx_hash);
|
||||
|
||||
// Can reverse lookup the key too
|
||||
let id = provider.transaction_id(tx.hash)?.ok_or(eyre::eyre!("txhash not found"))?;
|
||||
let id = provider.transaction_id(tx.hash())?.ok_or(eyre::eyre!("txhash not found"))?;
|
||||
assert_eq!(id, txid);
|
||||
|
||||
// Can find the block of a transaction given its key
|
||||
@ -171,7 +172,7 @@ fn receipts_provider_example<T: ReceiptProvider + TransactionsProvider + HeaderP
|
||||
// Can query receipt by txhash too
|
||||
let tx = provider.transaction_by_id(txid)?.unwrap();
|
||||
let receipt_by_hash =
|
||||
provider.receipt_by_hash(tx.hash)?.ok_or(eyre::eyre!("tx receipt by hash not found"))?;
|
||||
provider.receipt_by_hash(tx.hash())?.ok_or(eyre::eyre!("tx receipt by hash not found"))?;
|
||||
assert_eq!(receipt, receipt_by_hash);
|
||||
|
||||
// Can query all the receipts in a block
|
||||
|
||||
Reference in New Issue
Block a user