fixes vm state get block hash

This commit is contained in:
andri lim 2019-02-15 09:08:50 +07:00 committed by zah
parent 17188dfcb1
commit 04f28d9048
1 changed files with 8 additions and 5 deletions

View File

@ -66,12 +66,15 @@ method getAncestorHash*(vmState: BaseVMState, blockNumber: BlockNumber): Hash256
if ancestorDepth >= constants.MAX_PREV_HEADER_DEPTH or ancestorDepth < 0: if ancestorDepth >= constants.MAX_PREV_HEADER_DEPTH or ancestorDepth < 0:
return return
let idx = ancestorDepth.toInt result = vmState.chainDB.getBlockHash(blockNumber)
if idx >= vmState.prevHeaders.len: #TODO: should we use deque here?
return when false:
let idx = ancestorDepth.toInt
if idx >= vmState.prevHeaders.len:
return
var header = vmState.prevHeaders[idx] var header = vmState.prevHeaders[idx]
result = header.hash result = header.hash
when false: when false:
# this was an older version of `mutateStateDB`, kept here for reference # this was an older version of `mutateStateDB`, kept here for reference