From 1b097b5a8e282ba6bacf3b75d3227704b741f79b Mon Sep 17 00:00:00 2001 From: Jordan Hrycaj Date: Thu, 19 Dec 2024 10:07:57 +0000 Subject: [PATCH] No need to use extra table for persistent header cache state record why: Slot zero can do. This allows deleting that table wholesale when needed once thatfeature is available. --- nimbus/db/storage_types.nim | 8 +------- nimbus/sync/beacon/worker/db.nim | 4 ++-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/nimbus/db/storage_types.nim b/nimbus/db/storage_types.nim index 392048c677..e6eb411451 100644 --- a/nimbus/db/storage_types.nim +++ b/nimbus/db/storage_types.nim @@ -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 @@ -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 diff --git a/nimbus/sync/beacon/worker/db.nim b/nimbus/sync/beacon/worker/db.nim index 5496cbdc1e..c165b1421e 100644 --- a/nimbus/sync/beacon/worker/db.nim +++ b/nimbus/sync/beacon/worker/db.nim @@ -19,8 +19,8 @@ import ../worker_desc, ./headers_unproc -const - LhcStateKey = 1.beaconStateKey +let + LhcStateKey = 0.beaconHeaderKey # ------------------------------------------------------------------------------ # Private helpers