aboutsummaryrefslogtreecommitdiffstats
path: root/core/chain_manager.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-07-15 00:18:09 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-07-15 00:40:03 +0800
commite17d8ddbeb01a7e3eb745431d39c93661e167bbc (patch)
treef8814669fc41f220bc1173b58fdf23f27ce609ca /core/chain_manager.go
parent796c18db93add1d145db99d6088e445a56851e8b (diff)
downloaddexon-e17d8ddbeb01a7e3eb745431d39c93661e167bbc.tar.gz
dexon-e17d8ddbeb01a7e3eb745431d39c93661e167bbc.tar.zst
dexon-e17d8ddbeb01a7e3eb745431d39c93661e167bbc.zip
core: during chain reorg rewrite receipts and transactions
Added PutBlockReceipts; storing receipts by blocks. Eventually this will require pruning during some cleanup cycle. During forks the receipts by block are used to get the new canonical receipts and transactions. This PR fixes #1473 by rewriting transactions and receipts from the point of where the fork occured.
Diffstat (limited to 'core/chain_manager.go')
-rw-r--r--core/chain_manager.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/chain_manager.go b/core/chain_manager.go
index 8fa13ddec..1a703d084 100644
--- a/core/chain_manager.go
+++ b/core/chain_manager.go
@@ -667,6 +667,8 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {
queue[i] = ChainSplitEvent{block, logs}
queueEvent.splitCount++
}
+ PutBlockReceipts(self.extraDb, block, receipts)
+
stats.processed++
}
@@ -744,7 +746,12 @@ func (self *ChainManager) merge(oldBlock, newBlock *types.Block) error {
// insert blocks. Order does not matter. Last block will be written in ImportChain itself which creates the new head properly
self.mu.Lock()
for _, block := range newChain {
+ // insert the block in the canonical way, re-writing history
self.insert(block)
+ // write canonical receipts and transactions
+ PutTransactions(self.extraDb, block, block.Transactions())
+ PutReceipts(self.extraDb, GetBlockReceipts(self.extraDb, block.Hash()))
+
}
self.mu.Unlock()