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

Reorg the transaction module #54

Merged
merged 2 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
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
18 changes: 11 additions & 7 deletions src/block.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
use crate::{
util::ordered_trie_root, EnvelopedDecodable, EnvelopedEncodable, Header, PartialHeader,
TransactionAny, TransactionV0, TransactionV1, TransactionV2,
};
use alloc::vec::Vec;

use ethereum_types::H256;
use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream};
use rlp::{DecoderError, Rlp, RlpStream};
use sha3::{Digest, Keccak256};

use crate::{
enveloped::{EnvelopedDecodable, EnvelopedEncodable},
header::{Header, PartialHeader},
transaction::{TransactionAny, TransactionV0, TransactionV1, TransactionV2},
util::ordered_trie_root,
};

#[derive(Clone, Debug, PartialEq, Eq)]
#[cfg_attr(
feature = "with-codec",
Expand All @@ -19,7 +23,7 @@ pub struct Block<T> {
pub ommers: Vec<Header>,
}

impl<T: EnvelopedEncodable> Encodable for Block<T> {
impl<T: EnvelopedEncodable> rlp::Encodable for Block<T> {
fn rlp_append(&self, s: &mut RlpStream) {
s.begin_list(3);
s.append(&self.header);
Expand All @@ -34,7 +38,7 @@ impl<T: EnvelopedEncodable> Encodable for Block<T> {
}
}

impl<T: EnvelopedDecodable> Decodable for Block<T> {
impl<T: EnvelopedDecodable> rlp::Decodable for Block<T> {
fn decode(rlp: &Rlp) -> Result<Self, DecoderError> {
Ok(Self {
header: rlp.val_at(0)?,
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ pub mod util;
// Alias for `Vec<u8>`. This type alias is necessary for rlp-derive to work correctly.
type Bytes = alloc::vec::Vec<u8>;

pub use account::Account;
pub use block::*;
pub use enveloped::*;
pub use header::{Header, PartialHeader};
pub use log::Log;
pub use receipt::*;
pub use transaction::*;
pub use crate::account::Account;
pub use crate::block::*;
pub use crate::enveloped::*;
pub use crate::header::{Header, PartialHeader};
pub use crate::log::Log;
pub use crate::receipt::*;
pub use crate::transaction::*;
4 changes: 3 additions & 1 deletion src/log.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::Bytes;
use alloc::vec::Vec;

use ethereum_types::{H160, H256};

use crate::Bytes;

#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(rlp::RlpEncodable, rlp::RlpDecodable)]
#[cfg_attr(
Expand Down
7 changes: 6 additions & 1 deletion src/receipt.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
use crate::{EnvelopedDecodable, EnvelopedDecoderError, EnvelopedEncodable, Log};
use alloc::vec::Vec;

use bytes::BytesMut;
use ethereum_types::{Bloom, H256, U256};
use rlp::{Decodable, DecoderError, Rlp};

use crate::{
enveloped::{EnvelopedDecodable, EnvelopedDecoderError, EnvelopedEncodable},
log::Log,
};

#[derive(Clone, Debug, PartialEq, Eq)]
#[derive(rlp::RlpEncodable, rlp::RlpDecodable)]
#[cfg_attr(
Expand Down
Loading
Loading