// blockByNumber is a commonly used helper function which retrieves and returns the block for the given block number. It // returns nil when no block could be found. func blockByNumber(m *miner.Miner, bc *core.BlockChain, blockNr rpc.BlockNumber) *types.Block { if blockNr == rpc.PendingBlockNumber { return m.PendingBlock() } if blockNr == rpc.LatestBlockNumber { return bc.CurrentBlock() } return bc.GetBlockByNumber(uint64(blockNr)) }
func (self *GasPriceOracle) processPastBlocks(chain *core.BlockChain) { last := int64(-1) cblock := chain.CurrentBlock() if cblock != nil { last = int64(cblock.NumberU64()) } first := int64(0) if last > gpoProcessPastBlocks { first = last - gpoProcessPastBlocks } self.firstProcessed = uint64(first) for i := first; i <= last; i++ { block := chain.GetBlockByNumber(uint64(i)) if block != nil { self.processBlock(block) } } }