Skip to content

Commit

Permalink
core: Send removed=true TransactionEvent when a transaction is remove…
Browse files Browse the repository at this point in the history
…d due to a reorg
  • Loading branch information
reductionista committed Apr 25, 2018
1 parent d4ad5a0 commit 823bae2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -1184,10 +1184,6 @@ func (bc *BlockChain) insertChain(chain types.Blocks) (int, []interface{}, []*ty
common.PrettyDuration(time.Since(bstart)), "txs", len(block.Transactions()), "gas", block.GasUsed(), "uncles", len(block.Uncles()))

blockInsertTimer.UpdateSince(bstart)
for _, txPostEvent := range txPostEvents {
txPostEvent.RetData.Removed = true
events = append(events, txPostEvent)
}
events = append(events, ChainSideEvent{block})
}
stats.processed++
Expand Down Expand Up @@ -1342,10 +1338,12 @@ func (bc *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
}
// calculate the difference between deleted and added transactions
diff := types.TxDifference(deletedTxs, addedTxs)
// When transactions get deleted from the database that means the
// receipts that were created in the fork must also be deleted
for _, tx := range diff {
// When transactions get deleted from the database that means the
// receipts that were created in the fork must also be deleted
DeleteTxLookupEntry(bc.db, tx.Hash())
// Let ReturnData subscribers know when a transaction is removed from canonical chain
bc.txPostFeed.Send(TransactionEvent{TxHash: tx.Hash(), RetData: &types.ReturnData{TxHash: tx.Hash(), Removed: true}})
}
if len(deletedLogs) > 0 {
go bc.rmLogsFeed.Send(RemovedLogsEvent{deletedLogs})
Expand Down

0 comments on commit 823bae2

Please sign in to comment.