mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-02-27 16:17:22 +00:00
nil check
This commit is contained in:
parent
8119d77a21
commit
423beddf57
1 changed files with 8 additions and 1 deletions
|
|
@ -221,9 +221,16 @@ func (bc *BlockChain) GetChainFromHash(hash []byte, max uint64) []interface{} {
|
|||
startNumber := parentNumber + count
|
||||
|
||||
num := lastNumber
|
||||
for ; num > startNumber; currentHash = bc.GetBlock(currentHash).PrevHash {
|
||||
for num > startNumber {
|
||||
num--
|
||||
|
||||
block := bc.GetBlock(currentHash)
|
||||
if block == nil {
|
||||
break
|
||||
}
|
||||
currentHash = block.PrevHash
|
||||
}
|
||||
|
||||
for i := uint64(0); bytes.Compare(currentHash, hash) != 0 && num >= parentNumber && i < count; i++ {
|
||||
// Get the block of the chain
|
||||
block := bc.GetBlock(currentHash)
|
||||
|
|
|
|||
Loading…
Reference in a new issue