mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: accept AsRef in calculate_transaction_root (#2188)
This commit is contained in:
@ -36,12 +36,14 @@ impl Hasher for KeccakHasher {
|
|||||||
/// Calculate a transaction root.
|
/// Calculate a transaction root.
|
||||||
///
|
///
|
||||||
/// `(rlp(index), encoded(tx))` pairs.
|
/// `(rlp(index), encoded(tx))` pairs.
|
||||||
pub fn calculate_transaction_root<'a>(
|
pub fn calculate_transaction_root<I, T>(transactions: I) -> H256
|
||||||
transactions: impl IntoIterator<Item = &'a TransactionSigned>,
|
where
|
||||||
) -> H256 {
|
I: IntoIterator<Item = T>,
|
||||||
|
T: AsRef<TransactionSigned>,
|
||||||
|
{
|
||||||
ordered_trie_root::<KeccakHasher, _>(transactions.into_iter().map(|tx| {
|
ordered_trie_root::<KeccakHasher, _>(transactions.into_iter().map(|tx| {
|
||||||
let mut tx_rlp = Vec::new();
|
let mut tx_rlp = Vec::new();
|
||||||
tx.encode_inner(&mut tx_rlp, false);
|
tx.as_ref().encode_inner(&mut tx_rlp, false);
|
||||||
tx_rlp
|
tx_rlp
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -540,6 +540,12 @@ pub struct TransactionSigned {
|
|||||||
pub transaction: Transaction,
|
pub transaction: Transaction,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl AsRef<Self> for TransactionSigned {
|
||||||
|
fn as_ref(&self) -> &Self {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// === impl TransactionSigned ===
|
// === impl TransactionSigned ===
|
||||||
|
|
||||||
impl TransactionSigned {
|
impl TransactionSigned {
|
||||||
|
|||||||
Reference in New Issue
Block a user