aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorBas van Kervel <bas@ethdev.com>2016-07-26 22:37:04 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2016-08-18 21:25:16 +0800
commitc4ed34f008ae508549c03ec286467f48b188272f (patch)
treeb9bd0c063ce3b0cb3f54f98b7e84a5acd27439e6 /eth
parent0ab7e90cbbdf4a561748f20fe4825079013e15fa (diff)
downloadgo-tangerine-c4ed34f008ae508549c03ec286467f48b188272f.tar
go-tangerine-c4ed34f008ae508549c03ec286467f48b188272f.tar.gz
go-tangerine-c4ed34f008ae508549c03ec286467f48b188272f.tar.bz2
go-tangerine-c4ed34f008ae508549c03ec286467f48b188272f.tar.lz
go-tangerine-c4ed34f008ae508549c03ec286467f48b188272f.tar.xz
go-tangerine-c4ed34f008ae508549c03ec286467f48b188272f.tar.zst
go-tangerine-c4ed34f008ae508549c03ec286467f48b188272f.zip
[release/1.4.11] core: ensure the canonical block is written before the canonical hash is set
(cherry picked from commit bb8059f6aa86d1052d7c2dd75a6985982cb278f4) Conflicts: core/blockchain.go core/database_util.go core/headerchain.go eth/filters/filter.go
Diffstat (limited to 'eth')
-rw-r--r--eth/filters/filter.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/eth/filters/filter.go b/eth/filters/filter.go
index 469dfba4d..616184400 100644
--- a/eth/filters/filter.go
+++ b/eth/filters/filter.go
@@ -72,7 +72,11 @@ func (self *Filter) SetTopics(topics [][]common.Hash) {
// Run filters logs with the current parameters set
func (self *Filter) Find() vm.Logs {
- latestBlock := core.GetBlock(self.db, core.GetHeadBlockHash(self.db))
+ latestHash := core.GetHeadBlockHash(self.db)
+ latestBlock := core.GetBlock(self.db, latestHash)
+ if latestBlock == nil {
+ return vm.Logs{}
+ }
var beginBlockNo uint64 = uint64(self.begin)
if self.begin == -1 {
beginBlockNo = latestBlock.NumberU64()
@@ -122,13 +126,13 @@ func (self *Filter) mipFind(start, end uint64, depth int) (logs vm.Logs) {
}
func (self *Filter) getLogs(start, end uint64) (logs vm.Logs) {
- var block *types.Block
-
for i := start; i <= end; i++ {
+ var block *types.Block
hash := core.GetCanonicalHash(self.db, i)
if hash != (common.Hash{}) {
block = core.GetBlock(self.db, hash)
- } else { // block not found
+ }
+ if block == nil { // block not found/written
return logs
}