Retrieve parent block by hash, not by number

Weird that only hash works; add a TODO.
pull/839/head
Eugene Kim 6 years ago
parent e783c49d55
commit 04ba5a3adf
  1. 7
      consensus/consensus.go

@ -285,10 +285,13 @@ func accumulateRewards(
// Epoch block has no parent to reward.
return nil
}
parentHeader := bc.GetHeaderByNumber(blockNum - 1)
// TODO ek – retrieving by parent number (blockNum - 1) doesn't work,
// while it is okay with hash. Sounds like DB inconsistency.
// Figure out why.
parentHeader := bc.GetHeaderByHash(header.ParentHash)
if parentHeader == nil {
return ctxerror.New("cannot find parent block header in DB",
"parentBlockNumber", blockNum-1)
"parentHash", header.ParentHash)
}
if parentHeader.Number.Cmp(common.Big0) == 0 {
// Parent is an epoch block,

Loading…
Cancel
Save