From d8979dc6c36972d2a22ca4010dd16a77db520471 Mon Sep 17 00:00:00 2001 From: antonis19 Date: Thu, 21 Nov 2024 16:47:15 +0100 Subject: [PATCH 1/2] make MemoryMutation satisfy TemporalTx interface --- .../kv/membatchwithdb/memory_mutation.go | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/erigon-lib/kv/membatchwithdb/memory_mutation.go b/erigon-lib/kv/membatchwithdb/memory_mutation.go index 3bce9c02321..bc95552e153 100644 --- a/erigon-lib/kv/membatchwithdb/memory_mutation.go +++ b/erigon-lib/kv/membatchwithdb/memory_mutation.go @@ -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) *MemoryMutation { +func NewMemoryBatchWithCustomDB(tx kv.Tx, db kv.RwDB, uTx kv.RwTx, tmpDir string) *MemoryMutation { return &MemoryMutation{ db: tx, memDb: db, @@ -713,30 +713,31 @@ func (m *MemoryMutation) AggTx() any { } func (m *MemoryMutation) GetLatest(name kv.Domain, k, k2 []byte) (v []byte, step uint64, err error) { - panic("not supported") - //return m.db.(kv.TemporalTx).GetLatest(name, k, k2) + // panic("not supported") + return m.db.(kv.TemporalTx).GetLatest(name, k, k2) } func (m *MemoryMutation) GetAsOf(name kv.Domain, k, k2 []byte, ts uint64) (v []byte, ok bool, err error) { - panic("not supported") - //return m.db.(kv.TemporalTx).GetAsOf(name, k, k2, ts) + // panic("not supported") + return m.db.(kv.TemporalTx).GetAsOf(name, k, k2, ts) } -func (m *MemoryMutation) HistorySeek(name kv.History, k []byte, ts uint64) (v []byte, ok bool, err error) { - panic("not supported") - //return m.db.(kv.TemporalTx).HistorySeek(name, k, ts) + +func (m *MemoryMutation) RangeAsOf(name kv.Domain, fromKey, toKey []byte, ts uint64, asc order.By, limit int) (it stream.KV, err error) { + // panic("not supported") + return m.db.(kv.TemporalTx).RangeAsOf(name, fromKey, toKey, ts, asc, limit) } -func (m *MemoryMutation) IndexRange(name kv.InvertedIdx, k []byte, fromTs, toTs int, asc order.By, limit int) (timestamps stream.U64, err error) { +func (m *MemoryMutation) HistorySeek(name kv.Domain, k []byte, ts uint64) (v []byte, ok bool, err error) { panic("not supported") - //return m.db.(kv.TemporalTx).IndexRange(name, k, fromTs, toTs, asc, limit) + // return m.db.(kv.TemporalTx).HistorySeek(name, k, ts) } -func (m *MemoryMutation) HistoryRange(name kv.History, fromTs, toTs int, asc order.By, limit int) (it stream.KV, err error) { - panic("not supported") - //return m.db.(kv.TemporalTx).HistoryRange(name, fromTs, toTs, asc, limit) +func (m *MemoryMutation) IndexRange(name kv.InvertedIdx, k []byte, fromTs, toTs int, asc order.By, limit int) (timestamps stream.U64, err error) { + // panic("not supported") + return m.db.(kv.TemporalTx).IndexRange(name, k, fromTs, toTs, asc, limit) } -func (m *MemoryMutation) DomainRange(name kv.Domain, fromKey, toKey []byte, ts uint64, asc order.By, limit int) (it stream.KV, err error) { +func (m *MemoryMutation) HistoryRange(name kv.Domain, fromTs, toTs int, asc order.By, limit int) (it stream.KV, err error) { panic("not supported") - //return m.db.(kv.TemporalTx).RangeAsOf(name, fromKey, toKey, ts, asc, limit) + // return m.db.(kv.TemporalTx).HistoryRange(name, fromTs, toTs, asc, limit) } From b046efd2e89a70c8afa337e1cb82689b2b8484b5 Mon Sep 17 00:00:00 2001 From: antonis19 Date: Thu, 21 Nov 2024 16:50:02 +0100 Subject: [PATCH 2/2] remove tmp parameter --- erigon-lib/kv/membatchwithdb/memory_mutation.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/erigon-lib/kv/membatchwithdb/memory_mutation.go b/erigon-lib/kv/membatchwithdb/memory_mutation.go index bc95552e153..9033d9279ab 100644 --- a/erigon-lib/kv/membatchwithdb/memory_mutation.go +++ b/erigon-lib/kv/membatchwithdb/memory_mutation.go @@ -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,