Skip to content

Commit

Permalink
remove kv.InMem label - because db with any label can be InMem (#12772)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Nov 20, 2024
1 parent 2af372d commit 8dd289e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 18 deletions.
24 changes: 11 additions & 13 deletions erigon-lib/kv/kv_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ type DBVerbosityLvl int8
type Label uint8

const (
ChainDB Label = 0
TxPoolDB Label = 1
SentryDB Label = 2
ConsensusDB Label = 3
DownloaderDB Label = 4
InMem Label = 5
HeimdallDB Label = 6
DiagnosticsDB Label = 7
PolygonBridgeDB Label = 8
Unknown Label = iota
ChainDB
TxPoolDB
SentryDB
ConsensusDB
DownloaderDB
HeimdallDB
DiagnosticsDB
PolygonBridgeDB
)

func (l Label) String() string {
Expand All @@ -169,8 +169,6 @@ func (l Label) String() string {
return "consensus"
case DownloaderDB:
return "downloader"
case InMem:
return "inMem"
case HeimdallDB:
return "heimdall"
case DiagnosticsDB:
Expand All @@ -193,14 +191,14 @@ func UnmarshalLabel(s string) Label {
return ConsensusDB
case "downloader":
return DownloaderDB
case "inMem":
return InMem
case "heimdall":
return HeimdallDB
case "diagnostics":
return DiagnosticsDB
case "polygon-bridge":
return PolygonBridgeDB
case "unknown":
return Unknown
default:
panic(fmt.Sprintf("unexpected label: %s", s))
}
Expand Down
3 changes: 1 addition & 2 deletions erigon-lib/kv/mdbx/kv_mdbx.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func NewMDBX(log log.Logger) MdbxOpts {
growthStep: DefaultGrowthStep,
mergeThreshold: 2 * 8192,
shrinkThreshold: -1, // default
label: kv.InMem,
label: kv.Unknown,
}
return opts
}
Expand Down Expand Up @@ -142,7 +142,6 @@ func (opts MdbxOpts) InMem(tmpDir string) MdbxOpts {
opts.mapSize = 512 * datasize.MB
opts.dirtySpace = uint64(64 * datasize.MB)
opts.shrinkThreshold = 0 // disable
opts.label = kv.InMem
opts.pageSize = 4096
return opts
}
Expand Down
2 changes: 1 addition & 1 deletion erigon-lib/kv/mdbx/kv_mdbx_temporary.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func NewTemporaryMdbx(ctx context.Context, tempdir string) (kv.RwDB, error) {
return &TemporaryMdbx{}, err
}

db, err := NewMDBX(log.Root()).Label(kv.InMem).Label(kv.InMem).Path(path).Open(ctx)
db, err := NewMDBX(log.Root()).Label(kv.Unknown).InMem(path).Open(ctx)
if err != nil {
return &TemporaryMdbx{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion erigon-lib/kv/membatchwithdb/memory_mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func NewMemoryBatch(tx kv.Tx, tmpDir string, logger log.Logger) *MemoryMutation
}
}

func NewMemoryBatchWithCustomDB(tx kv.Tx, db kv.RwDB, uTx kv.RwTx, tmpDir string) *MemoryMutation {
func NewMemoryBatchWithCustomDB(tx kv.Tx, db kv.RwDB, uTx kv.RwTx) *MemoryMutation {
return &MemoryMutation{
db: tx,
memDb: db,
Expand Down
2 changes: 1 addition & 1 deletion turbo/engineapi/engine_block_downloader/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (e *EngineBlockDownloader) download(ctx context.Context, hashToDownload lib
}
defer tmpTx.Rollback()

memoryMutation := membatchwithdb.NewMemoryBatchWithCustomDB(tx, tmpDb, tmpTx, e.tmpdir)
memoryMutation := membatchwithdb.NewMemoryBatchWithCustomDB(tx, tmpDb, tmpTx)
defer memoryMutation.Rollback()

startBlock, endBlock, startHash, err := e.loadDownloadedHeaders(memoryMutation)
Expand Down

0 comments on commit 8dd289e

Please sign in to comment.