kv.Del() remove second parameter (#4832)

* save

* save

* save

* save

* save

* save

* save
This commit is contained in:
Alex Sharov 2022-07-26 12:47:05 +07:00 committed by GitHub
parent 60f1adddcd
commit b6ea28ea80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 80 additions and 86 deletions

View File

@ -819,7 +819,7 @@ func trimTxs(chaindata string) error {
txId := iter.Next()
var key [8]byte
binary.BigEndian.PutUint64(key[:], txId)
if err = txs.Delete(key[:], nil); err != nil {
if err = txs.Delete(key[:]); err != nil {
return err
}
deleted++

View File

@ -1065,7 +1065,7 @@ func printAppliedMigrations(db kv.RwDB, ctx context.Context) error {
func removeMigration(db kv.RwDB, ctx context.Context) error {
return db.Update(ctx, func(tx kv.RwTx) error {
return tx.Delete(kv.Migrations, []byte(migration), nil)
return tx.Delete(kv.Migrations, []byte(migration))
})
}

View File

@ -65,7 +65,7 @@ func TruncateCanonicalHash(tx kv.RwTx, blockFrom uint64, deleteHeaders bool) err
if deleteHeaders {
deleteHeader(tx, common.BytesToHash(v), blockFrom)
}
return tx.Delete(kv.HeaderCanonical, k, nil)
return tx.Delete(kv.HeaderCanonical, k)
}); err != nil {
return fmt.Errorf("TruncateCanonicalHash: %w", err)
}
@ -151,7 +151,7 @@ func WriteHeadBlockHash(db kv.Putter, hash common.Hash) {
// DeleteHeaderNumber removes hash->number mapping.
func DeleteHeaderNumber(db kv.Deleter, hash common.Hash) {
if err := db.Delete(kv.HeaderNumber, hash[:], nil); err != nil {
if err := db.Delete(kv.HeaderNumber, hash[:]); err != nil {
log.Crit("Failed to delete hash mapping", "err", err)
}
}
@ -333,10 +333,10 @@ func WriteHeader(db kv.Putter, header *types.Header) {
// deleteHeader - dangerous, use DeleteAncientBlocks/TruncateBlocks methods
func deleteHeader(db kv.Deleter, hash common.Hash, number uint64) {
if err := db.Delete(kv.Headers, dbutils.HeaderKey(number, hash), nil); err != nil {
if err := db.Delete(kv.Headers, dbutils.HeaderKey(number, hash)); err != nil {
log.Crit("Failed to delete header", "err", err)
}
if err := db.Delete(kv.HeaderNumber, hash.Bytes(), nil); err != nil {
if err := db.Delete(kv.HeaderNumber, hash.Bytes()); err != nil {
log.Crit("Failed to delete hash to number mapping", "err", err)
}
}
@ -710,7 +710,7 @@ func WriteSenders(db kv.Putter, hash common.Hash, number uint64, senders []commo
// deleteBody removes all block body data associated with a hash.
func deleteBody(db kv.Deleter, hash common.Hash, number uint64) {
if err := db.Delete(kv.BlockBody, dbutils.BlockBodyKey(number, hash), nil); err != nil {
if err := db.Delete(kv.BlockBody, dbutils.BlockBodyKey(number, hash)); err != nil {
log.Crit("Failed to delete block body", "err", err)
}
}
@ -746,7 +746,7 @@ func MakeBodiesCanonical(tx kv.RwTx, from uint64, ctx context.Context, logPrefix
if err := tx.Put(kv.EthTx, dbutils.EncodeBlockNumber(id), v); err != nil {
return err
}
if err := tx.Delete(kv.NonCanonicalTxs, k, nil); err != nil {
if err := tx.Delete(kv.NonCanonicalTxs, k); err != nil {
return err
}
i++
@ -814,7 +814,7 @@ func MakeBodiesNonCanonical(tx kv.RwTx, from uint64, deleteBodies bool, ctx cont
return err
}
}
if err := tx.Delete(kv.EthTx, k, nil); err != nil {
if err := tx.Delete(kv.EthTx, k); err != nil {
return err
}
i++
@ -901,7 +901,7 @@ func WriteTd(db kv.Putter, hash common.Hash, number uint64, td *big.Int) error {
// TruncateTd removes all block total difficulty from block number N
func TruncateTd(tx kv.RwTx, blockFrom uint64) error {
if err := tx.ForEach(kv.HeaderTD, dbutils.EncodeBlockNumber(blockFrom), func(k, _ []byte) error {
return tx.Delete(kv.HeaderTD, k, nil)
return tx.Delete(kv.HeaderTD, k)
}); err != nil {
return fmt.Errorf("TruncateTd: %w", err)
}
@ -1068,7 +1068,7 @@ func AppendReceipts(tx kv.StatelessWriteTx, blockNumber uint64, receipts types.R
// TruncateReceipts removes all receipt for given block number or newer
func TruncateReceipts(db kv.RwTx, number uint64) error {
if err := db.ForEach(kv.Receipts, dbutils.EncodeBlockNumber(number), func(k, _ []byte) error {
return db.Delete(kv.Receipts, k, nil)
return db.Delete(kv.Receipts, k)
}); err != nil {
return err
}
@ -1076,7 +1076,7 @@ func TruncateReceipts(db kv.RwTx, number uint64) error {
from := make([]byte, 8)
binary.BigEndian.PutUint64(from, number)
if err := db.ForEach(kv.Log, from, func(k, _ []byte) error {
return db.Delete(kv.Log, k, nil)
return db.Delete(kv.Log, k)
}); err != nil {
return err
}
@ -1228,7 +1228,7 @@ func DeleteAncientBlocks(tx kv.RwTx, blockTo uint64, blocksDeleteLimit int) (del
if !isCanonical {
bucket = kv.NonCanonicalTxs
}
if err = tx.Delete(bucket, txIDBytes, nil); err != nil {
if err = tx.Delete(bucket, txIDBytes); err != nil {
return
}
}
@ -1236,10 +1236,10 @@ func DeleteAncientBlocks(tx kv.RwTx, blockTo uint64, blocksDeleteLimit int) (del
// Copying k because otherwise the same memory will be reused
// for the next key and Delete below will end up deleting 1 more record than required
kCopy := common.CopyBytes(k)
if err = tx.Delete(kv.Headers, kCopy, nil); err != nil {
if err = tx.Delete(kv.Headers, kCopy); err != nil {
return
}
if err = tx.Delete(kv.BlockBody, kCopy, nil); err != nil {
if err = tx.Delete(kv.BlockBody, kCopy); err != nil {
return
}
}
@ -1335,7 +1335,7 @@ func TruncateBlocks(ctx context.Context, tx kv.RwTx, blockFrom uint64) error {
bucket = kv.NonCanonicalTxs
}
if err := tx.ForEach(bucket, dbutils.EncodeBlockNumber(b.BaseTxId), func(k, _ []byte) error {
if err := tx.Delete(bucket, k, nil); err != nil {
if err := tx.Delete(bucket, k); err != nil {
return err
}
return nil
@ -1349,10 +1349,10 @@ func TruncateBlocks(ctx context.Context, tx kv.RwTx, blockFrom uint64) error {
// Copying k because otherwise the same memory will be reused
// for the next key and Delete below will end up deleting 1 more record than required
kCopy := common.CopyBytes(k)
if err := tx.Delete(kv.Headers, kCopy, nil); err != nil {
if err := tx.Delete(kv.Headers, kCopy); err != nil {
return err
}
if err := tx.Delete(kv.BlockBody, kCopy, nil); err != nil {
if err := tx.Delete(kv.BlockBody, kCopy); err != nil {
return err
}
@ -1517,12 +1517,12 @@ func ReadAncestor(db kv.Getter, hash common.Hash, number, ancestor uint64, maxNo
func DeleteNewerEpochs(tx kv.RwTx, number uint64) error {
if err := tx.ForEach(kv.PendingEpoch, dbutils.EncodeBlockNumber(number), func(k, v []byte) error {
return tx.Delete(kv.Epoch, k, nil)
return tx.Delete(kv.Epoch, k)
}); err != nil {
return err
}
return tx.ForEach(kv.Epoch, dbutils.EncodeBlockNumber(number), func(k, v []byte) error {
return tx.Delete(kv.Epoch, k, nil)
return tx.Delete(kv.Epoch, k)
})
}
func ReadEpoch(tx kv.Tx, blockNum uint64, blockHash common.Hash) (transitionProof []byte, err error) {

View File

@ -60,7 +60,7 @@ func WriteTxLookupEntries(db kv.Putter, block *types.Block) {
// DeleteTxLookupEntry removes all transaction data associated with a hash.
func DeleteTxLookupEntry(db kv.Deleter, hash common.Hash) error {
return db.Delete(kv.TxLookup, hash.Bytes(), nil)
return db.Delete(kv.TxLookup, hash.Bytes())
}
// ReadTransactionByHash retrieves a specific transaction from the database, along with

View File

@ -59,5 +59,5 @@ func WriteChainConfig(db kv.Putter, hash common.Hash, cfg *params.ChainConfig) e
// DeleteChainConfig retrieves the consensus settings based on the given genesis hash.
func DeleteChainConfig(db kv.Deleter, hash common.Hash) error {
return db.Delete(kv.ConfigTable, hash[:], nil)
return db.Delete(kv.ConfigTable, hash[:])
}

View File

@ -113,7 +113,7 @@ func WriteBorReceipt(tx kv.RwTx, hash common.Hash, number uint64, borReceipt *ty
func DeleteBorReceipt(tx kv.RwTx, hash common.Hash, number uint64) {
key := borReceiptKey(number)
if err := tx.Delete(kv.BorReceipts, key, nil); err != nil {
if err := tx.Delete(kv.BorReceipts, key); err != nil {
log.Crit("Failed to delete bor receipt", "err", err)
}
}
@ -211,7 +211,7 @@ func computeBorTransactionForBlock(db kv.Tx, block *types.Block) (types.Transact
// TruncateBorReceipts removes all bor receipt for given block number or newer
func TruncateBorReceipts(db kv.RwTx, number uint64) error {
if err := db.ForEach(kv.BorReceipts, dbutils.EncodeBlockNumber(number), func(k, _ []byte) error {
return db.Delete(kv.BorReceipts, k, nil)
return db.Delete(kv.BorReceipts, k)
}); err != nil {
return err
}

View File

@ -70,7 +70,7 @@ func ResetBlocks(tx kv.RwTx) error {
}
// ensure no garbage records left (it may happen if db is inconsistent)
if err := tx.ForEach(kv.BlockBody, dbutils.EncodeBlockNumber(2), func(k, _ []byte) error { return tx.Delete(kv.BlockBody, k, nil) }); err != nil {
if err := tx.ForEach(kv.BlockBody, dbutils.EncodeBlockNumber(2), func(k, _ []byte) error { return tx.Delete(kv.BlockBody, k) }); err != nil {
return err
}
if err := tx.ClearBucket(kv.NonCanonicalTxs); err != nil {

View File

@ -1376,7 +1376,7 @@ func TestCacheCodeSizeInTrie(t *testing.T) {
assert.NoError(t, err, "you can receive the code size ")
assert.Equal(t, len(code), codeSize, "you can receive the code size")
assert.NoError(t, tx.Delete(kv.Code, codeHash[:], nil), nil)
assert.NoError(t, tx.Delete(kv.Code, codeHash[:]), nil)
codeSize2, err := r.ReadAccountCodeSize(contract, 1, codeHash)
assert.NoError(t, err, "you can still receive code size even with empty DB")

View File

@ -84,7 +84,7 @@ func (dsw *DbStateWriter) DeleteAccount(address common.Address, original *accoun
if err != nil {
return err
}
if err := dsw.db.Delete(kv.HashedAccounts, addrHash[:], nil); err != nil {
if err := dsw.db.Delete(kv.HashedAccounts, addrHash[:]); err != nil {
return err
}
if original.Incarnation > 0 {
@ -136,7 +136,7 @@ func (dsw *DbStateWriter) WriteAccountStorage(address common.Address, incarnatio
v := value.Bytes()
if len(v) == 0 {
return dsw.db.Delete(kv.HashedStorage, compositeKey, nil)
return dsw.db.Delete(kv.HashedStorage, compositeKey)
}
return dsw.db.Put(kv.HashedStorage, compositeKey, v)
}

View File

@ -82,7 +82,7 @@ func (w *PlainStateWriter) DeleteAccount(address common.Address, original *accou
if w.accumulator != nil {
w.accumulator.DeleteAccount(address)
}
if err := w.db.Delete(kv.PlainState, address[:], nil); err != nil {
if err := w.db.Delete(kv.PlainState, address[:]); err != nil {
return err
}
if original.Incarnation > 0 {
@ -112,7 +112,7 @@ func (w *PlainStateWriter) WriteAccountStorage(address common.Address, incarnati
w.accumulator.ChangeStorage(address, incarnation, *key, v)
}
if len(v) == 0 {
return w.db.Delete(kv.PlainState, compositeKey, nil)
return w.db.Delete(kv.PlainState, compositeKey)
}
return w.db.Put(kv.PlainState, compositeKey, v)
}

View File

@ -135,7 +135,7 @@ func (rs *ReconState1) Flush(rwTx kv.RwTx) error {
var err error
t.Ascend(func(item ReconStateItem1) bool {
if len(item.val) == 0 {
if err = rwTx.Delete(table, item.key, nil); err != nil {
if err = rwTx.Delete(table, item.key); err != nil {
return false
}
//fmt.Printf("Flush [%x]=>\n", ks)

View File

@ -489,7 +489,7 @@ func unwindExecutionStage(u *UnwindState, s *StageState, tx kv.RwTx, quit <-chan
if original != nil {
// clean up all the code incarnations original incarnation and the new one
for incarnation := original.Incarnation; incarnation > acc.Incarnation && incarnation > 0; incarnation-- {
err = tx.Delete(kv.PlainContractCode, dbutils.PlainGenerateStoragePrefix(address[:], incarnation), nil)
err = tx.Delete(kv.PlainContractCode, dbutils.PlainGenerateStoragePrefix(address[:], incarnation))
if err != nil {
return fmt.Errorf("writeAccountPlain for %x: %w", address, err)
}

View File

@ -256,7 +256,7 @@ func (p *HashPromoter) Promote(logPrefix string, s *StageState, from, to uint64,
slices.SortFunc(deletedAccounts, func(a, b []byte) bool { return bytes.Compare(a, b) < 0 })
for _, k := range deletedAccounts {
if err := p.db.ForPrefix(kv.TrieOfStorage, k, func(k, v []byte) error {
if err := p.db.Delete(kv.TrieOfStorage, k, v); err != nil {
if err := p.db.Delete(kv.TrieOfStorage, k); err != nil {
return err
}
return nil
@ -345,7 +345,7 @@ func (p *HashPromoter) Unwind(logPrefix string, s *StageState, u *UnwindState, s
slices.SortFunc(deletedAccounts, func(a, b []byte) bool { return bytes.Compare(a, b) < 0 })
for _, k := range deletedAccounts {
if err := p.db.ForPrefix(kv.TrieOfStorage, k, func(k, v []byte) error {
if err := p.db.Delete(kv.TrieOfStorage, k, v); err != nil {
if err := p.db.Delete(kv.TrieOfStorage, k); err != nil {
return err
}
return nil

View File

@ -274,9 +274,9 @@ func TestStorageDeletion(t *testing.T) {
// Delete storage and increment the trie
// ----------------------------------------------------------------
assert.Nil(t, tx.Delete(kv.HashedStorage, dbutils.GenerateCompositeStorageKey(hashedAddress, incarnation, hashedLocation1), value1))
assert.Nil(t, tx.Delete(kv.HashedStorage, dbutils.GenerateCompositeStorageKey(hashedAddress, incarnation, hashedLocation2), value2))
assert.Nil(t, tx.Delete(kv.HashedStorage, dbutils.GenerateCompositeStorageKey(hashedAddress, incarnation, hashedLocation3), value3))
assert.Nil(t, tx.Delete(kv.HashedStorage, dbutils.GenerateCompositeStorageKey(hashedAddress, incarnation, hashedLocation1)))
assert.Nil(t, tx.Delete(kv.HashedStorage, dbutils.GenerateCompositeStorageKey(hashedAddress, incarnation, hashedLocation2)))
assert.Nil(t, tx.Delete(kv.HashedStorage, dbutils.GenerateCompositeStorageKey(hashedAddress, incarnation, hashedLocation3)))
err = tx.Put(kv.StorageChangeSet, append(dbutils.EncodeBlockNumber(1), dbutils.PlainGenerateStoragePrefix(address[:], incarnation)...), plainLocation1[:])
assert.Nil(t, err)

View File

@ -334,7 +334,7 @@ func UnwindTranspileStage(u *UnwindState, s *StageState, tx kv.RwTx, cfg Transpi
continue
}
err = tx.Delete(kv.ContractTEVMCode, codeHashBytes, nil)
err = tx.Delete(kv.ContractTEVMCode, codeHashBytes)
if err != nil {
return fmt.Errorf("can't delete TEVM code by hash %q: %w", codeHash, err)
}

View File

@ -99,7 +99,7 @@ func TruncateRange(db kv.RwTx, bucket string, key []byte, to uint32) error {
if !bytes.HasPrefix(k, key) {
return false, nil
}
if err := db.Delete(bucket, k, nil); err != nil {
if err := db.Delete(bucket, k); err != nil {
return false, err
}
return true, nil
@ -253,7 +253,7 @@ func TruncateRange64(db kv.RwTx, bucket string, key []byte, to uint64) error {
if !bytes.HasPrefix(k, key) {
return false, nil
}
if err := cDel.Delete(k, nil); err != nil {
if err := cDel.Delete(k); err != nil {
return false, err
}
return true, nil

View File

@ -61,8 +61,8 @@ type Database interface {
// MinDatabase is a minimalistic version of the Database interface.
type MinDatabase interface {
Get(bucket string, key []byte) ([]byte, error)
Put(bucket string, key, value []byte) error
Delete(bucket string, k, v []byte) error
Put(table string, k, v []byte) error
Delete(table string, k []byte) error
}
// DbWithPendingMutations is an extended version of the Database,

View File

@ -88,7 +88,7 @@ func TestPutGet(t *testing.T) {
}
for _, v := range testValues {
err := tx.Delete(testBucket, []byte(v), nil)
err := tx.Delete(testBucket, []byte(v))
require.NoError(t, err)
}
@ -179,7 +179,7 @@ func TestParallelPutGet(t *testing.T) {
go func(key string) {
defer pending.Done()
_ = db.Update(context.Background(), func(tx kv.RwTx) error {
err := tx.Delete(testBucket, []byte(key), nil)
err := tx.Delete(testBucket, []byte(key))
if err != nil {
panic("delete failed: " + err.Error())
}

View File

@ -161,23 +161,23 @@ func (m *mapmutation) Has(table string, key []byte) (bool, error) {
}
// puts a table key with a value and if the table is not found then it appends a table
func (m *mapmutation) Put(table string, key []byte, value []byte) error {
func (m *mapmutation) Put(table string, k, v []byte) error {
m.mu.Lock()
defer m.mu.Unlock()
if _, ok := m.puts[table]; !ok {
m.puts[table] = make(map[string][]byte)
}
stringKey := *(*string)(unsafe.Pointer(&key))
stringKey := *(*string)(unsafe.Pointer(&k))
var ok bool
if _, ok = m.puts[table][stringKey]; !ok {
m.size += len(value) - len(m.puts[table][stringKey])
m.puts[table][stringKey] = value
m.size += len(v) - len(m.puts[table][stringKey])
m.puts[table][stringKey] = v
return nil
}
m.puts[table][stringKey] = value
m.size += len(key) + len(value)
m.puts[table][stringKey] = v
m.size += len(k) + len(v)
m.count++
return nil
}
@ -211,10 +211,7 @@ func (m *mapmutation) ForAmount(bucket string, prefix []byte, amount uint32, wal
return m.db.ForAmount(bucket, prefix, amount, walker)
}
func (m *mapmutation) Delete(table string, k, v []byte) error {
if v != nil {
return m.db.Delete(table, k, v) // TODO: mutation to support DupSort deletes
}
func (m *mapmutation) Delete(table string, k []byte) error {
return m.Put(table, k, nil)
}

View File

@ -183,13 +183,13 @@ func (m *mutation) Has(table string, key []byte) (bool, error) {
return false, nil
}
func (m *mutation) Put(table string, key []byte, value []byte) error {
func (m *mutation) Put(table string, k, v []byte) error {
m.mu.Lock()
defer m.mu.Unlock()
newMi := &MutationItem{table: table, key: key, value: value}
newMi := &MutationItem{table: table, key: k, value: v}
i := m.puts.ReplaceOrInsert(newMi)
m.size += int(unsafe.Sizeof(newMi)) + len(key) + len(value)
m.size += int(unsafe.Sizeof(newMi)) + len(k) + len(v)
if i != nil {
oldMi := i.(*MutationItem)
m.size -= (int(unsafe.Sizeof(oldMi)) + len(oldMi.key) + len(oldMi.value))
@ -226,10 +226,7 @@ func (m *mutation) ForAmount(bucket string, prefix []byte, amount uint32, walker
return m.db.ForAmount(bucket, prefix, amount, walker)
}
func (m *mutation) Delete(table string, k, v []byte) error {
if v != nil {
return m.db.Delete(table, k, v) // TODO: mutation to support DupSort deletes
}
func (m *mutation) Delete(table string, k []byte) error {
//m.puts.Delete(table, k)
return m.Put(table, k, nil)
}
@ -272,7 +269,7 @@ func (m *mutation) doCommit(tx kv.RwTx) error {
}
}
} else if len(mi.value) == 0 {
if err := c.Delete(mi.key, nil); err != nil {
if err := c.Delete(mi.key); err != nil {
innerErr = err
return false
}

View File

@ -41,9 +41,9 @@ func NewObjectDatabase(kv kv.RwDB) *ObjectDatabase {
}
// Put inserts or updates a single entry.
func (db *ObjectDatabase) Put(bucket string, key []byte, value []byte) error {
func (db *ObjectDatabase) Put(table string, k, v []byte) error {
err := db.kv.Update(context.Background(), func(tx kv.RwTx) error {
return tx.Put(bucket, key, value)
return tx.Put(table, k, v)
})
return err
}
@ -161,10 +161,10 @@ func (db *ObjectDatabase) ForPrefix(bucket string, prefix []byte, walker func(k,
}
// Delete deletes the key from the queue and database
func (db *ObjectDatabase) Delete(bucket string, k, v []byte) error {
func (db *ObjectDatabase) Delete(table string, k []byte) error {
// Execute the actual operation
err := db.kv.Update(context.Background(), func(tx kv.RwTx) error {
return tx.Delete(bucket, k, v)
return tx.Delete(table, k)
})
return err
}

View File

@ -66,13 +66,13 @@ func (m *TxDb) ReadSequence(bucket string) (res uint64, err error) {
return m.tx.ReadSequence(bucket)
}
func (m *TxDb) Put(bucket string, key []byte, value []byte) error {
m.len += uint64(len(key) + len(value))
c, err := m.cursor(bucket)
func (m *TxDb) Put(table string, k, v []byte) error {
m.len += uint64(len(k) + len(v))
c, err := m.cursor(table)
if err != nil {
return err
}
return c.(kv.RwCursor).Put(key, value)
return c.(kv.RwCursor).Put(k, v)
}
func (m *TxDb) Append(bucket string, key []byte, value []byte) error {
@ -93,13 +93,13 @@ func (m *TxDb) AppendDup(bucket string, key []byte, value []byte) error {
return c.(kv.RwCursorDupSort).AppendDup(key, value)
}
func (m *TxDb) Delete(bucket string, k, v []byte) error {
func (m *TxDb) Delete(table string, k []byte) error {
m.len += uint64(len(k))
c, err := m.cursor(bucket)
c, err := m.cursor(table)
if err != nil {
return err
}
return c.(kv.RwCursor).Delete(k, v)
return c.(kv.RwCursor).Delete(k)
}
func (m *TxDb) begin(ctx context.Context, flags ethdb.TxFlags) error {

2
go.mod
View File

@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon
go 1.18
require (
github.com/ledgerwatch/erigon-lib v0.0.0-20220726033341-68eb9dc34242
github.com/ledgerwatch/erigon-lib v0.0.0-20220726054309-8e7222cd32be
github.com/ledgerwatch/erigon-snapshot v1.0.0
github.com/ledgerwatch/log/v3 v3.4.1
github.com/ledgerwatch/secp256k1 v1.0.0

4
go.sum
View File

@ -390,8 +390,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0=
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
github.com/ledgerwatch/erigon-lib v0.0.0-20220726033341-68eb9dc34242 h1:lfe7qqh1abFhn+0pyEVLPc033u6toHhTXcr0EpPns0k=
github.com/ledgerwatch/erigon-lib v0.0.0-20220726033341-68eb9dc34242/go.mod h1:19wwSb5qbagorz9a4QN9FzNqSPjmOJkwa5TezGjloks=
github.com/ledgerwatch/erigon-lib v0.0.0-20220726054309-8e7222cd32be h1:DlrDNjVBEOpczYE7kUoaHnYGzKnOjqnBYlqmZkxv9fY=
github.com/ledgerwatch/erigon-lib v0.0.0-20220726054309-8e7222cd32be/go.mod h1:19wwSb5qbagorz9a4QN9FzNqSPjmOJkwa5TezGjloks=
github.com/ledgerwatch/erigon-snapshot v1.0.0 h1:bp/7xoPdM5lK7LFdqEMH008RZmqxMZV0RUVEQiWs7v4=
github.com/ledgerwatch/erigon-snapshot v1.0.0/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo=
github.com/ledgerwatch/log/v3 v3.4.1 h1:/xGwlVulXnsO9Uq+tzaExc8OWmXXHU0dnLalpbnY5Bc=

View File

@ -222,7 +222,7 @@ func (m *Migrator) Apply(db kv.RwDB, dataDir string) error {
return err
}
err = tx.Delete(kv.Migrations, []byte("_progress_"+v.Name), nil)
err = tx.Delete(kv.Migrations, []byte("_progress_"+v.Name))
if err != nil {
return err
}

View File

@ -100,14 +100,14 @@ var txsBeginEnd = Migration{
}
// del first tx in block
if err = tx.Delete(kv.EthTx, dbutils.EncodeBlockNumber(b.BaseTxId), nil); err != nil {
if err = tx.Delete(kv.EthTx, dbutils.EncodeBlockNumber(b.BaseTxId)); err != nil {
return err
}
if err := writeTransactionsNewDeprecated(tx, txs, b.BaseTxId+1); err != nil {
return fmt.Errorf("failed to write body txs: %w", err)
}
// del last tx in block
if err = tx.Delete(kv.EthTx, dbutils.EncodeBlockNumber(b.BaseTxId+uint64(b.TxAmount)-1), nil); err != nil {
if err = tx.Delete(kv.EthTx, dbutils.EncodeBlockNumber(b.BaseTxId+uint64(b.TxAmount)-1)); err != nil {
return err
}
@ -133,24 +133,24 @@ var txsBeginEnd = Migration{
for i := bodyForStorage.BaseTxId; i < bodyForStorage.BaseTxId+uint64(bodyForStorage.TxAmount); i++ {
binary.BigEndian.PutUint64(numBuf, i)
if err = tx.Delete(kv.NonCanonicalTxs, numBuf, nil); err != nil {
if err = tx.Delete(kv.NonCanonicalTxs, numBuf); err != nil {
return err
}
}
if err = tx.Delete(kv.BlockBody, k, nil); err != nil {
if err = tx.Delete(kv.BlockBody, k); err != nil {
return err
}
if err = tx.Delete(kv.Headers, k, nil); err != nil {
if err = tx.Delete(kv.Headers, k); err != nil {
return err
}
if err = tx.Delete(kv.HeaderTD, k, nil); err != nil {
if err = tx.Delete(kv.HeaderTD, k); err != nil {
return err
}
if err = tx.Delete(kv.HeaderNumber, k[8:], nil); err != nil {
if err = tx.Delete(kv.HeaderNumber, k[8:]); err != nil {
return err
}
if err = tx.Delete(kv.HeaderNumber, k[8:], nil); err != nil {
if err = tx.Delete(kv.HeaderNumber, k[8:]); err != nil {
return err
}
@ -314,7 +314,7 @@ func makeBodiesNonCanonicalDeprecated(tx kv.RwTx, from uint64, ctx context.Conte
return err
}
id++
return tx.Delete(kv.EthTx, k, nil)
return tx.Delete(kv.EthTx, k)
}); err != nil {
return err
}