mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-08 03:01:12 -04:00
chore: introduce receipts generic (#13276)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
//! Implements the `GetReceipts` and `Receipts` message types.
|
||||
|
||||
use alloy_consensus::{RlpDecodableReceipt, RlpEncodableReceipt};
|
||||
use alloy_primitives::B256;
|
||||
use alloy_rlp::{RlpDecodableWrapper, RlpEncodableWrapper};
|
||||
use reth_codecs_derive::add_arbitrary_tests;
|
||||
@@ -17,15 +18,33 @@ pub struct GetReceipts(
|
||||
|
||||
/// The response to [`GetReceipts`], containing receipt lists that correspond to each block
|
||||
/// requested.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, RlpEncodableWrapper, RlpDecodableWrapper, Default)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(any(test, feature = "arbitrary"), derive(arbitrary::Arbitrary))]
|
||||
#[add_arbitrary_tests(rlp)]
|
||||
pub struct Receipts(
|
||||
pub struct Receipts<T = Receipt>(
|
||||
/// Each receipt hash should correspond to a block hash in the request.
|
||||
pub Vec<Vec<ReceiptWithBloom<Receipt>>>,
|
||||
pub Vec<Vec<ReceiptWithBloom<T>>>,
|
||||
);
|
||||
|
||||
impl<T: RlpEncodableReceipt> alloy_rlp::Encodable for Receipts<T> {
|
||||
#[inline]
|
||||
fn encode(&self, out: &mut dyn alloy_rlp::BufMut) {
|
||||
self.0.encode(out)
|
||||
}
|
||||
#[inline]
|
||||
fn length(&self) -> usize {
|
||||
self.0.length()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: RlpDecodableReceipt> alloy_rlp::Decodable for Receipts<T> {
|
||||
#[inline]
|
||||
fn decode(buf: &mut &[u8]) -> alloy_rlp::Result<Self> {
|
||||
alloy_rlp::Decodable::decode(buf).map(Self)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{message::RequestPair, GetReceipts, Receipts};
|
||||
|
||||
Reference in New Issue
Block a user