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

eip2930: add payload methods for TxEip2930 #1218

Closed
wants to merge 3 commits 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
19 changes: 19 additions & 0 deletions crates/consensus/src/transaction/eip2930.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,25 @@ impl TxEip2930 {
pub const fn tx_type(&self) -> TxType {
TxType::Eip2930
}

/// Output the length of the RLP signed transaction encoding, _without_ a RLP string header.
pub fn payload_len_with_signature_without_header<S>(&self, signature: &S) -> usize
where
S: EncodableSignature,
{
let payload_length = self.fields_len() + signature.rlp_vrs_len();
// 'transaction type byte length' + 'header length' + 'payload length'
1 + length_of_length(payload_length) + payload_length
}

/// Output the length of the RLP signed transaction encoding. This encodes with a RLP header.
pub fn payload_len_with_signature<S>(&self, signature: &S) -> usize
where
S: EncodableSignature,
{
let len = self.payload_len_with_signature_without_header(signature);
length_of_length(len) + len
}
}

impl Transaction for TxEip2930 {
Expand Down