diff options
Diffstat (limited to 'ethchain/block_chain.go')
-rw-r--r-- | ethchain/block_chain.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/ethchain/block_chain.go b/ethchain/block_chain.go index c8e5c610e..467c54058 100644 --- a/ethchain/block_chain.go +++ b/ethchain/block_chain.go @@ -236,6 +236,16 @@ func (self *BlockChain) GetBlockByNumber(num uint64) *Block { return block } +func (self *BlockChain) GetBlockBack(num uint64) *Block { + block := self.CurrentBlock + + for ; num != 0 && block != nil; num-- { + block = self.GetBlock(block.PrevHash) + } + + return block +} + func (bc *BlockChain) BlockInfoByHash(hash []byte) BlockInfo { bi := BlockInfo{} data, _ := ethutil.Config.Db.Get(append(hash, []byte("Info")...)) |