本文整理汇总了Golang中github.com/gophergala2016/etherapis/etherapis/Godeps/_workspace/src/github.com/ethereum/go-ethereum/core.BlockChain.GetBlockByNumber方法的典型用法代码示例。如果您正苦于以下问题:Golang BlockChain.GetBlockByNumber方法的具体用法?Golang BlockChain.GetBlockByNumber怎么用?Golang BlockChain.GetBlockByNumber使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/gophergala2016/etherapis/etherapis/Godeps/_workspace/src/github.com/ethereum/go-ethereum/core.BlockChain
的用法示例。
在下文中一共展示了BlockChain.GetBlockByNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: blockByNumber
// 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: processPastBlocks
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)
}
}
}