Add pebble Batch implementation for db.Tx

Add pebble Batch implementation for db.Tx, and update db.Tx Put & Add methods
to return error.
This commit is contained in:
arnaucube
2020-09-02 14:33:54 +02:00
parent 3093442590
commit eeb949f8c3
6 changed files with 96 additions and 62 deletions

View File

@@ -83,8 +83,9 @@ func (tx *MemoryStorageTx) Get(key []byte) ([]byte, error) {
}
// Put implements the method Put of the interface db.Tx
func (tx *MemoryStorageTx) Put(k, v []byte) {
func (tx *MemoryStorageTx) Put(k, v []byte) error {
tx.kv.Put(db.Concat(tx.s.prefix, k), v)
return nil
}
// Commit implements the method Commit of the interface db.Tx
@@ -97,11 +98,12 @@ func (tx *MemoryStorageTx) Commit() error {
}
// Add implements the method Add of the interface db.Tx
func (tx *MemoryStorageTx) Add(atx db.Tx) {
func (tx *MemoryStorageTx) Add(atx db.Tx) error {
mstx := atx.(*MemoryStorageTx)
for _, v := range mstx.kv {
tx.kv.Put(v.K, v.V)
}
return nil
}
// Close implements the method Close of the interface db.Tx