示例#1
0
文件: api.go 项目: efaysal/etherapis
// 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))
}
示例#2
0
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)
		}
	}

}