Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix clippy issues in develop #460

Closed
wants to merge 1 commit into from
Closed
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
71 changes: 0 additions & 71 deletions trace_decoder/src/typed_mpt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,6 @@ impl TriePath {
pub fn from_hash(H256(bytes): H256) -> Self {
Self::new(AsNibbles(bytes)).expect("32 bytes is 64 nibbles, which fits")
}
fn from_txn_ix(txn_ix: usize) -> Self {
TriePath::new(AsNibbles(rlp::encode(&txn_ix))).expect(
"\
rlp of an usize goes through a u64, which is 8 bytes,
which will be 9 bytes RLP'ed.
9 < 32",
)
}
fn into_nibbles(self) -> mpt_trie::nibbles::Nibbles {
let mut theirs = mpt_trie::nibbles::Nibbles::default();
for component in self.0 {
Expand All @@ -163,60 +155,6 @@ impl TriePath {
}
}

/// Per-block, `txn_ix -> [u8]`.
///
/// See <https://ethereum.org/en/developers/docs/data-structures-and-encoding/patricia-merkle-trie/#receipts-trie>
#[derive(Debug, Clone, Default)]
pub struct TransactionTrie {
untyped: HashedPartialTrie,
}

impl TransactionTrie {
pub fn insert(&mut self, txn_ix: usize, val: Vec<u8>) -> Result<Option<Vec<u8>>, Error> {
let prev = self
.untyped
.get(TriePath::from_txn_ix(txn_ix).into_nibbles())
.map(Vec::from);
self.untyped
.insert(TriePath::from_txn_ix(txn_ix).into_nibbles(), val)
.map_err(|source| Error { source })?;
Ok(prev)
}
pub fn root(&self) -> H256 {
self.untyped.hash()
}
pub fn as_hashed_partial_trie(&self) -> &mpt_trie::partial_trie::HashedPartialTrie {
&self.untyped
}
}

/// Per-block, `txn_ix -> [u8]`.
///
/// See <https://ethereum.org/en/developers/docs/data-structures-and-encoding/patricia-merkle-trie/#transaction-trie>
#[derive(Debug, Clone, Default)]
pub struct ReceiptTrie {
untyped: HashedPartialTrie,
}

impl ReceiptTrie {
pub fn insert(&mut self, txn_ix: usize, val: Vec<u8>) -> Result<Option<Vec<u8>>, Error> {
let prev = self
.untyped
.get(TriePath::from_txn_ix(txn_ix).into_nibbles())
.map(Vec::from);
self.untyped
.insert(TriePath::from_txn_ix(txn_ix).into_nibbles(), val)
.map_err(|source| Error { source })?;
Ok(prev)
}
pub fn root(&self) -> H256 {
self.untyped.hash()
}
pub fn as_hashed_partial_trie(&self) -> &mpt_trie::partial_trie::HashedPartialTrie {
&self.untyped
}
}

/// Global, [`Address`] `->` [`AccountRlp`].
///
/// See <https://ethereum.org/en/developers/docs/data-structures-and-encoding/patricia-merkle-trie/#state-trie>
Expand Down Expand Up @@ -300,16 +238,7 @@ impl StorageTrie {
pub fn root(&self) -> H256 {
self.untyped.hash()
}
pub fn remove(&mut self, path: TriePath) -> Result<Option<Vec<u8>>, Error> {
self.untyped
.delete(path.into_nibbles())
.map_err(|source| Error { source })
}
pub fn as_hashed_partial_trie(&self) -> &mpt_trie::partial_trie::HashedPartialTrie {
&self.untyped
}

pub fn as_mut_hashed_partial_trie_unchecked(&mut self) -> &mut HashedPartialTrie {
&mut self.untyped
}
}
Loading