mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 23:25:22 +00:00
storage: add bloom filter to leveldb
We're constantly checking for transactions there and most of the time this check is not successful (meaning that the transaction in question is new). Bloom filter easily reduces the need to search over the DB in 99% of these cases and gives some 13% increase in single-node TPS.
This commit is contained in:
parent
f5f58a7e91
commit
bc31ab3d2c
1 changed files with 3 additions and 1 deletions
|
@ -2,6 +2,7 @@ package storage
|
|||
|
||||
import (
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
"github.com/syndtr/goleveldb/leveldb/filter"
|
||||
"github.com/syndtr/goleveldb/leveldb/opt"
|
||||
"github.com/syndtr/goleveldb/leveldb/util"
|
||||
)
|
||||
|
@ -21,8 +22,9 @@ type LevelDBStore struct {
|
|||
// NewLevelDBStore returns a new LevelDBStore object that will
|
||||
// initialize the database found at the given path.
|
||||
func NewLevelDBStore(cfg LevelDBOptions) (*LevelDBStore, error) {
|
||||
var opts *opt.Options // should be exposed via LevelDBOptions if anything needed
|
||||
var opts = new(opt.Options) // should be exposed via LevelDBOptions if anything needed
|
||||
|
||||
opts.Filter = filter.NewBloomFilter(10)
|
||||
db, err := leveldb.OpenFile(cfg.DataDirectoryPath, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in a new issue