Skip to content

Commit

Permalink
Add #[doc(hidden)] to exposed low-level encoding functions
Browse files Browse the repository at this point in the history
  • Loading branch information
clabby committed Apr 16, 2024
1 parent 1956325 commit c5f2436
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/consensus/src/transaction/eip1559.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ impl TxEip1559 {
}

/// Outputs the length of the transaction's fields, without a RLP header.
#[doc(hidden)]
pub fn fields_len(&self) -> usize {
let mut len = 0;
len += self.chain_id.length();
Expand Down Expand Up @@ -176,6 +177,7 @@ impl TxEip1559 {

/// Inner encoding function that is used for both rlp [`Encodable`] trait and for calculating
/// hash that for eip2718 does not require a rlp header.
#[doc(hidden)]
pub fn encode_with_signature(
&self,
signature: &Signature,
Expand All @@ -200,6 +202,7 @@ impl TxEip1559 {
/// header.
///
/// This __does__ expect the bytes to start with a list header and include a signature.
#[doc(hidden)]
pub fn decode_signed_fields(buf: &mut &[u8]) -> alloy_rlp::Result<Signed<Self>> {
let header = Header::decode(buf)?;
if !header.list {
Expand Down
3 changes: 3 additions & 0 deletions crates/consensus/src/transaction/eip2930.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ impl TxEip2930 {
}

/// Outputs the length of the transaction's fields, without a RLP header.
#[doc(hidden)]
pub fn fields_len(&self) -> usize {
let mut len = 0;
len += self.chain_id.length();
Expand Down Expand Up @@ -154,6 +155,7 @@ impl TxEip2930 {

/// Inner encoding function that is used for both rlp [`Encodable`] trait and for calculating
/// hash that for eip2718 does not require a rlp header
#[doc(hidden)]
pub fn encode_with_signature(
&self,
signature: &Signature,
Expand Down Expand Up @@ -190,6 +192,7 @@ impl TxEip2930 {
/// header.
///
/// This __does__ expect the bytes to start with a list header and include a signature.
#[doc(hidden)]
pub fn decode_signed_fields(buf: &mut &[u8]) -> alloy_rlp::Result<Signed<Self>> {
let header = Header::decode(buf)?;
if !header.list {
Expand Down
7 changes: 7 additions & 0 deletions crates/consensus/src/transaction/eip4844.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ impl TxEip4844Variant {
}

/// Outputs the length of the transaction's fields, without a RLP header.
#[doc(hidden)]
pub fn fields_len(&self) -> usize {
match self {
TxEip4844Variant::TxEip4844(tx) => tx.fields_len(),
Expand All @@ -161,6 +162,7 @@ impl TxEip4844Variant {
///
/// If `with_header` is `true`, the following will be encoded:
/// `rlp(tx_type (0x03) || rlp([transaction_payload_body, blobs, commitments, proofs]))`
#[doc(hidden)]
pub fn encode_with_signature(
&self,
signature: &Signature,
Expand Down Expand Up @@ -203,6 +205,7 @@ impl TxEip4844Variant {
/// header.
///
/// This __does__ expect the bytes to start with a list header and include a signature.
#[doc(hidden)]
pub fn decode_signed_fields(buf: &mut &[u8]) -> alloy_rlp::Result<Signed<Self>> {
let mut current_buf = *buf;
let _header = Header::decode(&mut current_buf)?;
Expand Down Expand Up @@ -517,6 +520,7 @@ impl TxEip4844 {
}

/// Outputs the length of the transaction's fields, without a RLP header.
#[doc(hidden)]
pub fn fields_len(&self) -> usize {
let mut len = 0;
len += self.chain_id.length();
Expand Down Expand Up @@ -595,6 +599,7 @@ impl TxEip4844 {

/// Inner encoding function that is used for both rlp [`Encodable`] trait and for calculating
/// hash that for eip2718 does not require a rlp header
#[doc(hidden)]
pub fn encode_with_signature(
&self,
signature: &Signature,
Expand Down Expand Up @@ -631,6 +636,7 @@ impl TxEip4844 {
/// header.
///
/// This __does__ expect the bytes to start with a list header and include a signature.
#[doc(hidden)]
pub fn decode_signed_fields(buf: &mut &[u8]) -> alloy_rlp::Result<Signed<Self>> {
let header = Header::decode(buf)?;
if !header.list {
Expand Down Expand Up @@ -865,6 +871,7 @@ impl TxEip4844WithSidecar {
/// This __does__ expect the bytes to start with a list header and include a signature.
///
/// This is the inverse of [TxEip4844WithSidecar::encode_with_signature_fields].
#[doc(hidden)]
pub fn decode_signed_fields(buf: &mut &[u8]) -> alloy_rlp::Result<Signed<Self>> {
let header = Header::decode(buf)?;
if !header.list {
Expand Down
2 changes: 2 additions & 0 deletions crates/consensus/src/transaction/legacy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ impl TxLegacy {

/// Outputs the length of the transaction's fields, without a RLP header or length of the
/// eip155 fields.
#[doc(hidden)]
pub fn fields_len(&self) -> usize {
let mut len = 0;
len += self.nonce.length();
Expand Down Expand Up @@ -153,6 +154,7 @@ impl TxLegacy {
/// header.
///
/// This __does__ expect the bytes to start with a list header and include a signature.
#[doc(hidden)]
pub fn decode_signed_fields(buf: &mut &[u8]) -> alloy_rlp::Result<Signed<Self>> {
let header = Header::decode(buf)?;
if !header.list {
Expand Down

0 comments on commit c5f2436

Please sign in to comment.