Skip to content

Commit 5d9df73

Browse files
zsfelfoldiobscuren
authored andcommitted
gpo non-existent block checks
1 parent ac80ec5 commit 5d9df73

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

eth/gasprice.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,21 @@ func NewGasPriceOracle(eth *Ethereum) (self *GasPriceOracle) {
4747
}
4848

4949
func (self *GasPriceOracle) processPastBlocks() {
50-
last := self.chain.CurrentBlock().NumberU64()
51-
first := uint64(0)
50+
last := int64(-1)
51+
cblock := self.chain.CurrentBlock()
52+
if cblock != nil {
53+
last = int64(cblock.NumberU64())
54+
}
55+
first := int64(0)
5256
if last > gpoProcessPastBlocks {
5357
first = last - gpoProcessPastBlocks
5458
}
55-
self.firstProcessed = first
59+
self.firstProcessed = uint64(first)
5660
for i := first; i <= last; i++ {
57-
self.processBlock(self.chain.GetBlockByNumber(i))
61+
block := self.chain.GetBlockByNumber(uint64(i))
62+
if block != nil {
63+
self.processBlock(block)
64+
}
5865
}
5966

6067
}

0 commit comments

Comments
 (0)