diff options
author | Felix Lange <fjl@twurst.com> | 2016-08-17 02:16:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-17 02:16:48 +0800 |
commit | c2ac4465cd83b45bdfe520001fc2fe2dac6bae24 (patch) | |
tree | 44c57f98592518652f9791655be98c75fc198760 /eth | |
parent | 4c2cc32f2e279baa3059603b8c8a4329f31606f6 (diff) | |
parent | bb8059f6aa86d1052d7c2dd75a6985982cb278f4 (diff) | |
download | go-tangerine-c2ac4465cd83b45bdfe520001fc2fe2dac6bae24.tar go-tangerine-c2ac4465cd83b45bdfe520001fc2fe2dac6bae24.tar.gz go-tangerine-c2ac4465cd83b45bdfe520001fc2fe2dac6bae24.tar.bz2 go-tangerine-c2ac4465cd83b45bdfe520001fc2fe2dac6bae24.tar.lz go-tangerine-c2ac4465cd83b45bdfe520001fc2fe2dac6bae24.tar.xz go-tangerine-c2ac4465cd83b45bdfe520001fc2fe2dac6bae24.tar.zst go-tangerine-c2ac4465cd83b45bdfe520001fc2fe2dac6bae24.zip |
Merge pull request #2873 from bas-vk/canonicalblock
core: ensure the canonical block is written before the canonical hash is set
Diffstat (limited to 'eth')
-rw-r--r-- | eth/filters/filter.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/eth/filters/filter.go b/eth/filters/filter.go index 995b588fb..fd739bf0e 100644 --- a/eth/filters/filter.go +++ b/eth/filters/filter.go @@ -74,6 +74,9 @@ func (self *Filter) SetTopics(topics [][]common.Hash) { func (self *Filter) Find() vm.Logs { latestHash := core.GetHeadBlockHash(self.db) latestBlock := core.GetBlock(self.db, latestHash, core.GetBlockNumber(self.db, latestHash)) + if latestBlock == nil { + return vm.Logs{} + } var beginBlockNo uint64 = uint64(self.begin) if self.begin == -1 { beginBlockNo = latestBlock.NumberU64() @@ -123,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, i) - } else { // block not found + } + if block == nil { // block not found/written return logs } |