Skip to content
Merged
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
32 changes: 23 additions & 9 deletions core/rawdb/chain_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ func InitDatabaseFromFreezer(db ctxcdb.Database) {
type blockTxHashes struct {
number uint64
hashes []common.Hash
err error
}

// iterateTransactions iterates over all transactions in the (canon) block
Expand Down Expand Up @@ -143,17 +144,22 @@ func iterateTransactions(db ctxcdb.Database, from uint64, to uint64, reverse boo
}()
for data := range rlpCh {
var body types.Body
var result *blockTxHashes
if err := rlp.DecodeBytes(data.rlp, &body); err != nil {
log.Warn("Failed to decode block body", "block", data.number, "error", err)
return
}
var hashes []common.Hash
for _, tx := range body.Transactions {
hashes = append(hashes, tx.Hash())
}
result := &blockTxHashes{
hashes: hashes,
number: data.number,
result = &blockTxHashes{
number: data.number,
err: err,
}
} else {
var hashes []common.Hash
for _, tx := range body.Transactions {
hashes = append(hashes, tx.Hash())
}
result = &blockTxHashes{
hashes: hashes,
number: data.number,
}
}
// Feed the block to the aggregator, or abort on interrupt
select {
Expand Down Expand Up @@ -213,6 +219,10 @@ func indexTransactions(db ctxcdb.Database, from uint64, to uint64, interrupt cha
// Next block available, pop it off and index it
delivery := queue.PopItem()
lastNum = delivery.number
if delivery.err != nil {
log.Warn("Skipping tx indexing for block with missing/corrupt body", "block", delivery.number, "error", delivery.err)
continue
}
WriteTxLookupEntries(batch, delivery.number, delivery.hashes)
blocks++
txs += len(delivery.hashes)
Expand Down Expand Up @@ -306,6 +316,10 @@ func unindexTransactions(db ctxcdb.Database, from uint64, to uint64, interrupt c
}
delivery := queue.PopItem()
nextNum = delivery.number + 1
if delivery.err != nil {
log.Warn("Skipping tx unindexing for block with missing/corrupt body", "block", delivery.number, "error", delivery.err)
continue
}
DeleteTxLookupEntries(batch, delivery.hashes)
txs += len(delivery.hashes)
blocks++
Expand Down
Loading