-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinterface.go
37 lines (27 loc) · 1.09 KB
/
interface.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package badger
import (
"io"
"github.com/pokt-network/smt/kvstore"
)
// Ensure the BadgerKVStore can be used as an SMT node store
var _ kvstore.MapStore = (BadgerKVStore)(nil)
// BadgerKVStore is an interface that defines a key-value store
// that can be used standalone or as the node store for an SMT.
// This is a superset of the MapStore interface that offers more
// features and can be used as a standalone key-value store.
type BadgerKVStore interface {
kvstore.MapStore
// --- Lifecycle methods ---
// Stop closes the database connection, disabling any access to the store
Stop() error
// --- Data methods ---
// Backup creates a full backup of the store written to the provided writer
Backup(writer io.Writer, incremental bool) error
// Restore loads the store from a backup in the reader provided
Restore(io.Reader) error
// --- Accessors ---
// GetAll returns all keys and values with the given prefix in the specified order
GetAll(prefixKey []byte, descending bool) (keys, values [][]byte, err error)
// Exists returns true if the key exists
Exists(key []byte) (bool, error)
}