mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
fix(db): off by one receipts insert (#1993)
This commit is contained in:
@ -576,12 +576,19 @@ impl PostState {
|
||||
bytecodes_cursor.upsert(hash, bytecode)?;
|
||||
}
|
||||
|
||||
// write receipts
|
||||
// write the receipts of the transactions
|
||||
let mut receipts_cursor = tx.cursor_write::<tables::Receipts>()?;
|
||||
let mut tx_num = receipts_cursor.last()?.map(|(tx_num, _)| tx_num).unwrap_or_default();
|
||||
|
||||
let mut next_tx_num =
|
||||
if let Some(last_tx) = receipts_cursor.last()?.map(|(tx_num, _)| tx_num) {
|
||||
last_tx + 1
|
||||
} else {
|
||||
// the very first tx
|
||||
0
|
||||
};
|
||||
for receipt in self.receipts.into_iter() {
|
||||
tx_num += 1;
|
||||
receipts_cursor.append(tx_num, receipt)?
|
||||
receipts_cursor.append(next_tx_num, receipt)?;
|
||||
next_tx_num += 1;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user