reth_provider/writer/
database.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
use alloy_primitives::{BlockNumber, TxNumber};
use reth_db::{
    cursor::{DbCursorRO, DbCursorRW},
    tables,
};
use reth_errors::ProviderResult;
use reth_primitives::Receipt;
use reth_storage_api::ReceiptWriter;

pub(crate) struct DatabaseWriter<'a, W>(pub(crate) &'a mut W);

impl<W> ReceiptWriter for DatabaseWriter<'_, W>
where
    W: DbCursorRO<tables::Receipts> + DbCursorRW<tables::Receipts>,
{
    fn append_block_receipts(
        &mut self,
        first_tx_index: TxNumber,
        _: BlockNumber,
        receipts: Vec<Option<Receipt>>,
    ) -> ProviderResult<()> {
        for (tx_idx, receipt) in receipts.into_iter().enumerate() {
            if let Some(receipt) = receipt {
                self.0.append(first_tx_index + tx_idx as u64, receipt)?;
            }
        }
        Ok(())
    }
}