make some 'beginTransaction' usages safer
This commit is contained in:
parent
b8ada41ce0
commit
48cdc6da0b
|
@ -19,19 +19,17 @@ proc executeBlock(blockEnv: JsonNode, memoryDB: TrieDatabaseRef, blockNumber: Ui
|
|||
header = chainDB.getBlockHeader(blockNumber)
|
||||
body = chainDB.getBlockBody(header.blockHash)
|
||||
|
||||
let transaction = memoryDB.beginTransaction()
|
||||
defer: transaction.dispose()
|
||||
let
|
||||
transaction = memoryDB.beginTransaction()
|
||||
vmState = newBaseVMState(parent, chainDB)
|
||||
validationResult = processBlock(chainDB, parent, header, body, vmState)
|
||||
|
||||
if validationResult != ValidationResult.OK:
|
||||
if validationResult != ValidationResult.OK:
|
||||
error "block validation error", validationResult
|
||||
else:
|
||||
info "block validation success", validationResult, blockNumber
|
||||
|
||||
# success or not dispose it
|
||||
transaction.dispose()
|
||||
|
||||
dumpDebuggingMetaData(chainDB, header, body, vmState, false)
|
||||
let
|
||||
fileName = "debug" & $blockNumber & ".json"
|
||||
|
|
|
@ -16,8 +16,9 @@ proc dumpDebug(chainDB: BaseChainDB, blockNumber: Uint256) =
|
|||
captureTrieDB = trieDB captureDB
|
||||
captureChainDB = newBaseChainDB(captureTrieDB, false)
|
||||
|
||||
let transaction = memoryDB.beginTransaction()
|
||||
defer: transaction.dispose()
|
||||
let
|
||||
transaction = memoryDB.beginTransaction()
|
||||
parentNumber = blockNumber - 1
|
||||
parent = captureChainDB.getBlockHeader(parentNumber)
|
||||
header = captureChainDB.getBlockHeader(blockNumber)
|
||||
|
@ -28,8 +29,6 @@ proc dumpDebug(chainDB: BaseChainDB, blockNumber: Uint256) =
|
|||
captureChainDB.setHead(parent, true)
|
||||
let validationResult = processBlock(captureChainDB, parent, header, body, vmState)
|
||||
|
||||
# success or not dispose it
|
||||
transaction.dispose()
|
||||
dumpDebuggingMetaData(captureChainDB, header, body, vmState, false)
|
||||
|
||||
proc main() =
|
||||
|
|
|
@ -68,13 +68,13 @@ proc huntProblematicBlock(blockNumber: Uint256): ValidationResult =
|
|||
|
||||
chainDB.setHead(parentBlock.header, true)
|
||||
|
||||
let transaction = memoryDB.beginTransaction()
|
||||
defer: transaction.dispose()
|
||||
let
|
||||
transaction = memoryDB.beginTransaction()
|
||||
vmState = newBaseVMState(parentBlock.header, chainDB)
|
||||
validationResult = processBlock(chainDB, parentBlock.header, thisBlock.header, thisBlock.body, vmState)
|
||||
|
||||
if validationResult != ValidationResult.OK:
|
||||
transaction.dispose()
|
||||
dumpDebuggingMetaData(chainDB, thisBlock.header, thisBlock.body, vmState, false)
|
||||
|
||||
result = validationResult
|
||||
|
|
Loading…
Reference in New Issue