mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
libs/db: fix boltdb batching
`[]byte` is unhashable and needs to be casted to a string. See https://github.com/tendermint/tendermint/pull/3610#discussion_r280995538 Ref https://github.com/tendermint/tendermint/issues/3626
This commit is contained in:
parent
60b833403c
commit
d0d9ef16f7
@ -161,11 +161,11 @@ func (bdb *BoltDB) NewBatch() Batch {
|
||||
}
|
||||
|
||||
func (bdb *boltDBBatch) Set(key, value []byte) {
|
||||
bdb.buffer.Store(key, value)
|
||||
bdb.buffer.Store(string(key), value)
|
||||
}
|
||||
|
||||
func (bdb *boltDBBatch) Delete(key []byte) {
|
||||
bdb.buffer.Delete(key)
|
||||
bdb.buffer.Delete(string(key))
|
||||
}
|
||||
|
||||
// NOTE: the operation is synchronous (see BoltDB for reasons)
|
||||
@ -174,7 +174,7 @@ func (bdb *boltDBBatch) Write() {
|
||||
b := tx.Bucket(bucket)
|
||||
var putErr error
|
||||
bdb.buffer.Range(func(key, value interface{}) bool {
|
||||
putErr = b.Put(key.([]byte), value.([]byte))
|
||||
putErr = b.Put([]byte(key.(string)), value.([]byte))
|
||||
return putErr == nil // stop if putErr is not nil
|
||||
})
|
||||
return putErr
|
||||
|
Loading…
x
Reference in New Issue
Block a user