2020-03-24 02:12:55 +00:00
|
|
|
package ethdb
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-06-04 09:35:42 +00:00
|
|
|
|
|
|
|
"github.com/ledgerwatch/turbo-geth/common"
|
2020-03-24 02:12:55 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type KV interface {
|
2020-05-27 16:24:34 +00:00
|
|
|
View(ctx context.Context, f func(tx Tx) error) error
|
|
|
|
Update(ctx context.Context, f func(tx Tx) error) error
|
2020-04-04 07:18:10 +00:00
|
|
|
Close()
|
|
|
|
|
|
|
|
Begin(ctx context.Context, writable bool) (Tx, error)
|
2020-03-24 02:12:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Tx interface {
|
|
|
|
Bucket(name []byte) Bucket
|
2020-04-04 07:18:10 +00:00
|
|
|
|
|
|
|
Commit(ctx context.Context) error
|
|
|
|
Rollback() error
|
2020-03-24 02:12:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Bucket interface {
|
|
|
|
Get(key []byte) (val []byte, err error)
|
|
|
|
Put(key []byte, value []byte) error
|
|
|
|
Delete(key []byte) error
|
|
|
|
Cursor() Cursor
|
|
|
|
}
|
|
|
|
|
|
|
|
type Cursor interface {
|
|
|
|
Prefix(v []byte) Cursor
|
|
|
|
MatchBits(uint) Cursor
|
|
|
|
Prefetch(v uint) Cursor
|
|
|
|
NoValues() NoValuesCursor
|
|
|
|
|
|
|
|
First() ([]byte, []byte, error)
|
|
|
|
Seek(seek []byte) ([]byte, []byte, error)
|
2020-05-15 08:58:36 +00:00
|
|
|
SeekTo(seek []byte) ([]byte, []byte, error)
|
2020-03-24 02:12:55 +00:00
|
|
|
Next() ([]byte, []byte, error)
|
|
|
|
Walk(walker func(k, v []byte) (bool, error)) error
|
2020-06-04 11:19:59 +00:00
|
|
|
|
|
|
|
Put(key []byte, value []byte) error
|
|
|
|
Delete(key []byte) error
|
2020-03-24 02:12:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type NoValuesCursor interface {
|
2020-04-04 07:18:10 +00:00
|
|
|
First() ([]byte, uint32, error)
|
|
|
|
Seek(seek []byte) ([]byte, uint32, error)
|
|
|
|
Next() ([]byte, uint32, error)
|
|
|
|
Walk(walker func(k []byte, vSize uint32) (bool, error)) error
|
2020-03-24 02:12:55 +00:00
|
|
|
}
|
|
|
|
|
2020-06-04 09:35:42 +00:00
|
|
|
type HasStats interface {
|
|
|
|
DiskSize(context.Context) (common.StorageSize, error) // db size
|
|
|
|
BucketsStat(context.Context) (map[string]common.StorageBucketWriteStats, error)
|
|
|
|
}
|
|
|
|
|
2020-03-24 02:12:55 +00:00
|
|
|
type DbProvider uint8
|
|
|
|
|
|
|
|
const (
|
|
|
|
Bolt DbProvider = iota
|
|
|
|
Badger
|
|
|
|
Remote
|
|
|
|
)
|