diff options
author | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-08-31 23:09:50 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-10-04 07:13:56 +0800 |
commit | 7c7692933c21b77328a94eed714f66c276776197 (patch) | |
tree | f7a394c1823dd4da1ed2b37709c1c8f52c51b6ef /eth/filters/filter.go | |
parent | 361082ec4b942aea7c01fcb1be1782cb68b6fe3a (diff) | |
download | go-tangerine-7c7692933c21b77328a94eed714f66c276776197.tar go-tangerine-7c7692933c21b77328a94eed714f66c276776197.tar.gz go-tangerine-7c7692933c21b77328a94eed714f66c276776197.tar.bz2 go-tangerine-7c7692933c21b77328a94eed714f66c276776197.tar.lz go-tangerine-7c7692933c21b77328a94eed714f66c276776197.tar.xz go-tangerine-7c7692933c21b77328a94eed714f66c276776197.tar.zst go-tangerine-7c7692933c21b77328a94eed714f66c276776197.zip |
cmd/geth, cmd/utils, core, rpc: renamed to blockchain
* Renamed ChainManager to BlockChain
* Checkpointing is no longer required and never really properly worked
when the state was corrupted.
Diffstat (limited to 'eth/filters/filter.go')
-rw-r--r-- | eth/filters/filter.go | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/eth/filters/filter.go b/eth/filters/filter.go index 0b4911629..2bcf20d0c 100644 --- a/eth/filters/filter.go +++ b/eth/filters/filter.go @@ -1,4 +1,4 @@ -// Copyright 2014 The go-ethereum Authors +// Copyright 2015 The go-ethereum Authors // This file is part of the go-ethereum library. // // The go-ethereum library is free software: you can redistribute it and/or modify @@ -23,6 +23,7 @@ import ( "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" + "github.com/ethereum/go-ethereum/ethdb" ) type AccountChange struct { @@ -31,7 +32,7 @@ type AccountChange struct { // Filtering interface type Filter struct { - db common.Database + db ethdb.Database earliest int64 latest int64 skip int @@ -46,7 +47,7 @@ type Filter struct { // Create a new filter which uses a bloom filter on blocks to figure out whether a particular block // is interesting or not. -func New(db common.Database) *Filter { +func New(db ethdb.Database) *Filter { return &Filter{db: db} } @@ -79,7 +80,7 @@ func (self *Filter) SetSkip(skip int) { // Run filters logs with the current parameters set func (self *Filter) Find() vm.Logs { - earliestBlock := core.GetCurrentBlock(self.db) + earliestBlock := core.GetBlock(self.db, core.GetHeadBlockHash(self.db)) var earliestBlockNo uint64 = uint64(self.earliest) if self.earliest == -1 { earliestBlockNo = earliestBlock.NumberU64() @@ -91,8 +92,12 @@ func (self *Filter) Find() vm.Logs { var ( logs vm.Logs - block = core.GetBlockByNumber(self.db, latestBlockNo) + block *types.Block ) + hash := core.GetCanonicalHash(self.db, latestBlockNo) + if hash != (common.Hash{}) { + block = core.GetBlock(self.db, hash) + } done: for i := 0; block != nil; i++ { @@ -120,7 +125,7 @@ done: logs = append(logs, self.FilterLogs(unfiltered)...) } - block = core.GetBlockByHash(self.db, block.ParentHash()) + block = core.GetBlock(self.db, block.ParentHash()) } skip := int(math.Min(float64(len(logs)), float64(self.skip))) |