From d0d9ef16f76a5845557cf3189dd6eef803a38aed Mon Sep 17 00:00:00 2001 From: Leo Date: Mon, 6 May 2019 20:10:39 +0000 Subject: [PATCH] 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 --- libs/db/boltdb.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/db/boltdb.go b/libs/db/boltdb.go index d5b6f5864..7ee988d2e 100644 --- a/libs/db/boltdb.go +++ b/libs/db/boltdb.go @@ -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