mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-24 22:32:15 +00:00
Description: add boltdb implement for db interface. The boltdb is safe and high performence embedded KV database. It is based on B+tree and Mmap. Now it is maintained by etcd-io org. https://github.com/etcd-io/bbolt It is much better than LSM tree (levelDB) when RANDOM and SCAN read. Replaced #3604 Refs #1835 Commits: * add boltdb for storage * update boltdb in gopkg.toml * update bbolt in Gopkg.lock * dep update Gopkg.lock * add boltdb'bucket when create Boltdb * some modifies * address my own comments * fix most of the Iterator tests for boltdb * bolt does not support concurrent writes while iterating * add WARNING word * note that ReadOnly option is not supported * fixes after Ismail's review Co-Authored-By: melekes <anton.kalyaev@gmail.com> * panic if View returns error plus specify bucket in the top comment
36 lines
624 B
Go
36 lines
624 B
Go
package db
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
cmn "github.com/tendermint/tendermint/libs/common"
|
|
)
|
|
|
|
func TestBoltDBNewBoltDB(t *testing.T) {
|
|
name := fmt.Sprintf("test_%x", cmn.RandStr(12))
|
|
dir := os.TempDir()
|
|
defer cleanupDBDir(dir, name)
|
|
|
|
db, err := NewBoltDB(name, dir)
|
|
require.NoError(t, err)
|
|
db.Close()
|
|
}
|
|
|
|
func BenchmarkBoltDBRandomReadsWrites(b *testing.B) {
|
|
name := fmt.Sprintf("test_%x", cmn.RandStr(12))
|
|
db, err := NewBoltDB(name, "")
|
|
if err != nil {
|
|
b.Fatal(err)
|
|
}
|
|
defer func() {
|
|
db.Close()
|
|
cleanupDBDir("", name)
|
|
}()
|
|
|
|
benchmarkRandomReadsWrites(b, db)
|
|
}
|