aboutsummaryrefslogtreecommitdiffstats
path: root/core/blockchain.go
diff options
context:
space:
mode:
authorJeffrey Wilcke <geffobscura@gmail.com>2015-10-12 23:58:51 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-10-17 03:28:59 +0800
commit6dc14788a238f3e0ec786c6c04d476a3b957e645 (patch)
tree8f3f5f91506bc4c7532543043add1eaea3fd28e7 /core/blockchain.go
parent30f057aaf9891fb37f82d94c24b8aa35d388e07b (diff)
downloadgo-tangerine-6dc14788a238f3e0ec786c6c04d476a3b957e645.tar.gz
go-tangerine-6dc14788a238f3e0ec786c6c04d476a3b957e645.tar.zst
go-tangerine-6dc14788a238f3e0ec786c6c04d476a3b957e645.zip
core, eth/filters, miner, xeth: Optimised log filtering
Log filtering is now using a MIPmap like approach where addresses of logs are added to a mapped bloom bin. The current levels for the MIP are in ranges of 1.000.000, 500.000, 100.000, 50.000, 1.000. Logs are therefor filtered in batches of 1.000.
Diffstat (limited to 'core/blockchain.go')
-rw-r--r--core/blockchain.go27
1 files changed, 22 insertions, 5 deletions
diff --git a/core/blockchain.go b/core/blockchain.go
index 6c555e9ee..5cb800f1d 100644
--- a/core/blockchain.go
+++ b/core/blockchain.go
@@ -654,10 +654,17 @@ func (self *BlockChain) InsertChain(chain types.Blocks) (int, error) {
events = append(events, ChainEvent{block, block.Hash(), logs})
// This puts transactions in a extra db for rpc
- PutTransactions(self.chainDb, block, block.Transactions())
+ if err := PutTransactions(self.chainDb, block, block.Transactions()); err != nil {
+ return i, err
+ }
// store the receipts
- PutReceipts(self.chainDb, receipts)
-
+ if err := PutReceipts(self.chainDb, receipts); err != nil {
+ return i, err
+ }
+ // Write map map bloom filters
+ if err := WriteMipmapBloom(self.chainDb, block.NumberU64(), receipts); err != nil {
+ return i, err
+ }
case SideStatTy:
if glog.V(logger.Detail) {
glog.Infof("inserted forked block #%d (TD=%v) (%d TXs %d UNCs) (%x...). Took %v\n", block.Number(), block.Difficulty(), len(block.Transactions()), len(block.Uncles()), block.Hash().Bytes()[0:4], time.Since(bstart))
@@ -743,8 +750,18 @@ func (self *BlockChain) reorg(oldBlock, newBlock *types.Block) error {
// insert the block in the canonical way, re-writing history
self.insert(block)
// write canonical receipts and transactions
- PutTransactions(self.chainDb, block, block.Transactions())
- PutReceipts(self.chainDb, GetBlockReceipts(self.chainDb, block.Hash()))
+ if err := PutTransactions(self.chainDb, block, block.Transactions()); err != nil {
+ return err
+ }
+ receipts := GetBlockReceipts(self.chainDb, block.Hash())
+ // write receipts
+ if err := PutReceipts(self.chainDb, receipts); err != nil {
+ return err
+ }
+ // Write map map bloom filters
+ if err := WriteMipmapBloom(self.chainDb, block.NumberU64(), receipts); err != nil {
+ return err
+ }
addedTxs = append(addedTxs, block.Transactions()...)
}