aboutsummaryrefslogtreecommitdiffstats
path: root/eth
diff options
context:
space:
mode:
authorzsfelfoldi <zsfelfoldi@gmail.com>2015-06-29 19:48:10 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-06-30 00:53:04 +0800
commit5d9df7348d80fbd5de9a92d7f6abe6c02646c24d (patch)
treed98a93c563abd9a5d010c8458886b4d3a6dd3fd1 /eth
parentac80ec59dc223c679639aaae9a42325e18cde9c8 (diff)
downloadgo-tangerine-5d9df7348d80fbd5de9a92d7f6abe6c02646c24d.tar
go-tangerine-5d9df7348d80fbd5de9a92d7f6abe6c02646c24d.tar.gz
go-tangerine-5d9df7348d80fbd5de9a92d7f6abe6c02646c24d.tar.bz2
go-tangerine-5d9df7348d80fbd5de9a92d7f6abe6c02646c24d.tar.lz
go-tangerine-5d9df7348d80fbd5de9a92d7f6abe6c02646c24d.tar.xz
go-tangerine-5d9df7348d80fbd5de9a92d7f6abe6c02646c24d.tar.zst
go-tangerine-5d9df7348d80fbd5de9a92d7f6abe6c02646c24d.zip
gpo non-existent block checks
Diffstat (limited to 'eth')
-rw-r--r--eth/gasprice.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/eth/gasprice.go b/eth/gasprice.go
index 44202d709..ddf1c8c09 100644
--- a/eth/gasprice.go
+++ b/eth/gasprice.go
@@ -47,14 +47,21 @@ func NewGasPriceOracle(eth *Ethereum) (self *GasPriceOracle) {
}
func (self *GasPriceOracle) processPastBlocks() {
- last := self.chain.CurrentBlock().NumberU64()
- first := uint64(0)
+ last := int64(-1)
+ cblock := self.chain.CurrentBlock()
+ if cblock != nil {
+ last = int64(cblock.NumberU64())
+ }
+ first := int64(0)
if last > gpoProcessPastBlocks {
first = last - gpoProcessPastBlocks
}
- self.firstProcessed = first
+ self.firstProcessed = uint64(first)
for i := first; i <= last; i++ {
- self.processBlock(self.chain.GetBlockByNumber(i))
+ block := self.chain.GetBlockByNumber(uint64(i))
+ if block != nil {
+ self.processBlock(block)
+ }
}
}