aboutsummaryrefslogtreecommitdiffstats
path: root/core/blockchain.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2016-12-05 02:07:24 +0800
committerFelix Lange <fjl@twurst.com>2016-12-05 17:57:11 +0800
commitf52a1ae849492480b6505ab7805305640518a568 (patch)
tree95918d77278e15d7dfd52ad24a967d291f6cfdcb /core/blockchain.go
parent3bc0fe1ee3183311efe851aca8fd10d5a5433929 (diff)
downloaddexon-f52a1ae849492480b6505ab7805305640518a568.tar.gz
dexon-f52a1ae849492480b6505ab7805305640518a568.tar.zst
dexon-f52a1ae849492480b6505ab7805305640518a568.zip
core, core/vm, eth/filters: move Removed field into vm.Log
This field used to be assigned by the filter system and returned through the RPC API. Now that we have a Go client that uses the underlying type, the field needs to move. It is now assigned to true when the RemovedLogs event is generated so the filter system doesn't need to care about the field at all. While here, remove the log list from ChainSideEvent. There are no users of this field right now and any potential users could subscribe to RemovedLogsEvent instead.
Diffstat (limited to 'core/blockchain.go')
-rw-r--r--core/blockchain.go29
1 files changed, 15 insertions, 14 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 2eb207d39..1f762d147 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -988,7 +988,7 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
glog.Infof("inserted forked block #%d [%x…] (TD=%v) in %9v: %3d txs %d uncles.", block.Number(), block.Hash().Bytes()[0:4], block.Difficulty(), common.PrettyDuration(time.Since(bstart)), len(block.Transactions()), len(block.Uncles()))
}
blockInsertTimer.UpdateSince(bstart)
- events = append(events, ChainSideEvent{block, logs})
+ events = append(events, ChainSideEvent{block})
case SplitStatTy:
events = append(events, ChainSplitEvent{block, logs})
@@ -1062,24 +1062,25 @@ func countTransactions(chain []*types.Block) (c int) {
// event about them
func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
var (
- newChain types.Blocks
- oldChain types.Blocks
- commonBlock *types.Block
- oldStart = oldBlock
- newStart = newBlock
- deletedTxs types.Transactions
- deletedLogs vm.Logs
- deletedLogsByHash = make(map[common.Hash]vm.Logs)
+ newChain types.Blocks
+ oldChain types.Blocks
+ commonBlock *types.Block
+ oldStart = oldBlock
+ newStart = newBlock
+ deletedTxs types.Transactions
+ deletedLogs vm.Logs
// collectLogs collects the logs that were generated during the
// processing of the block that corresponds with the given hash.
// These logs are later announced as deleted.
collectLogs = func(h common.Hash) {
- // Coalesce logs
+ // Coalesce logs and set 'Removed'.
receipts := GetBlockReceipts(self.chainDb, h, self.hc.GetBlockNumber(h))
for _, receipt := range receipts {
- deletedLogs = append(deletedLogs, receipt.Logs...)
-
- deletedLogsByHash[h] = receipt.Logs
+ for _, log := range receipt.Logs {
+ del := *log
+ del.Removed = true
+ deletedLogs = append(deletedLogs, &del)
+ }
}
}
)
@@ -1173,7 +1174,7 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
if len(oldChain) > 0 {
go func() {
for _, block := range oldChain {
- self.eventMux.Post(ChainSideEvent{Block: block, Logs: deletedLogsByHash[block.Hash()]})
+ self.eventMux.Post(ChainSideEvent{Block: block})
}
}()
}