Skip to content
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