From 823bae28c84315f9c45e69c6a6e1d27ca36a5db3 Mon Sep 17 00:00:00 2001 From: Domino Valdano Date: Mon, 23 Apr 2018 20:28:05 -0700 Subject: [PATCH] core: Send removed=true TransactionEvent when a transaction is removed due to a reorg --- core/blockchain.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 9e3b3d708d..a76663fb5a 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -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++ @@ -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})