Skip to content

Commit

Permalink
nim 1.2 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
arnetheduck committed Jan 4, 2023
1 parent fa20d4d commit be2d053
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions beacon_chain/beacon_chain_db.nim
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ proc loadImmutableValidators(vals: DbSeq[ImmutableValidatorDataDb2]): seq[Immuta
pubkey: tmp.pubkey.loadValid(),
withdrawal_credentials: tmp.withdrawal_credentials)

template withManyWrites*(dbParam: BeaconChainDB, body: untyped): untyped =
template withManyWrites*(dbParam: BeaconChainDB, body: untyped) =
let
db = dbParam
nested = isInsideTransaction(db.db)
Expand All @@ -433,13 +433,8 @@ template withManyWrites*(dbParam: BeaconChainDB, body: untyped): untyped =
expectDb db.db.exec("BEGIN TRANSACTION;")
var commit = false
try:
when typeof(body) is void:
block: body
body
commit = true
else:
let res = block: body
commit = true
res
finally:
if not nested:
if commit:
Expand Down Expand Up @@ -847,9 +842,11 @@ proc putStateDiff*(db: BeaconChainDB, root: Eth2Digest, value: BeaconStateDiff)
db.stateDiffs.putSnappySSZ(root.data, value)

proc delBlock*(db: BeaconChainDB, fork: BeaconBlockFork, key: Eth2Digest): bool =
var deleted = false
db.withManyWrites:
discard db.summaries.del(key.data).expectDb()
db.blocks[fork].del(key.data).expectDb()
deleted = db.blocks[fork].del(key.data).expectDb()
deleted

proc delState*(db: BeaconChainDB, fork: BeaconStateFork, key: Eth2Digest) =
discard db.statesNoVal[fork].del(key.data).expectDb()
Expand Down

0 comments on commit be2d053

Please sign in to comment.