Skip to content

Commit

Permalink
No need to use extra table for persistent header cache state record
Browse files Browse the repository at this point in the history
why:
  Slot zero can do. This allows deleting that table wholesale when needed
  once thatfeature is available.
  • Loading branch information
mjfh committed Dec 19, 2024
1 parent c7055bb commit 1b097b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
8 changes: 1 addition & 7 deletions nimbus/db/storage_types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ type
dataDirId = 7
safeHash = 8
finalizedHash = 9
beaconState = 10
beaconHeader = 11
beaconHeader = 10

DbKey* = object
# The first byte stores the key type. The rest are key-specific values
Expand Down Expand Up @@ -87,11 +86,6 @@ func hashIndexKey*(hash: Hash32, index: uint16): HashIndexKey =
result[32] = byte(index and 0xFF)
result[33] = byte((index shl 8) and 0xFF)

func beaconStateKey*(u: uint8): DbKey =
result.data[0] = byte ord(beaconState)
result.data[1] = u
result.dataEndPos = 1

func beaconHeaderKey*(u: BlockNumber): DbKey =
result.data[0] = byte ord(beaconHeader)
doAssert sizeof(u) <= 32
Expand Down
4 changes: 2 additions & 2 deletions nimbus/sync/beacon/worker/db.nim
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import
../worker_desc,
./headers_unproc

const
LhcStateKey = 1.beaconStateKey
let
LhcStateKey = 0.beaconHeaderKey

# ------------------------------------------------------------------------------
# Private helpers
Expand Down

0 comments on commit 1b097b5

Please sign in to comment.