mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-23 12:07:17 +00:00
Sequence in to mdbx (#1370)
This commit is contained in:
parent
068463dff4
commit
ccd1ad5832
@ -359,10 +359,23 @@ func toMdbx(ctx context.Context, from, to string) error {
|
||||
if b.Flags&dbutils.DupSort != 0 && !b.AutoDupSortKeysConversion {
|
||||
appendFunc = c.(ethdb.CursorDupSort).AppendDup
|
||||
}
|
||||
if b.Flags&dbutils.DupFixed != 0 && !b.AutoDupSortKeysConversion {
|
||||
appendFunc = c.(ethdb.CursorDupSort).AppendDup
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// migrate bucket sequences to native mdbx implementation
|
||||
currentID, err := srcTx.Sequence(name, 0)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = dstTx.Sequence(name, currentID+1)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
err := dstTx.Commit(context.Background())
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -719,6 +719,10 @@ func (tx *lmdbTx) Sequence(bucket string, amount uint64) (uint64, error) {
|
||||
currentV = binary.BigEndian.Uint64(v)
|
||||
}
|
||||
|
||||
if amount == 0 {
|
||||
return currentV, nil
|
||||
}
|
||||
|
||||
newVBytes := make([]byte, 8)
|
||||
binary.BigEndian.PutUint64(newVBytes, currentV+amount)
|
||||
err = c.Put([]byte(bucket), newVBytes)
|
||||
|
Loading…
Reference in New Issue
Block a user