mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-27 05:57:28 +00:00
9324d83cb2
* - handle cursor.Prefix on server - move state reports to KV interface * add CmdCursorSeekKey * tests for abstract_kv * avoid reading configs of databases * avoid reading configs of databases * make linter happy * make linter happy * cleanup * port badger features from original implementation * try to fix test * try to fix test * .Close() don't return error anymore - defer friendly * try to enable badger now * try to enable badger now * badger can't run on CI yet * badger can't run on CI yet * re-run ci * skip ctx cancelation for badger
55 lines
1.0 KiB
Go
55 lines
1.0 KiB
Go
package ethdb
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
type KV interface {
|
|
View(ctx context.Context, f func(tx Tx) error) (err error)
|
|
Update(ctx context.Context, f func(tx Tx) error) (err error)
|
|
Close()
|
|
|
|
Begin(ctx context.Context, writable bool) (Tx, error)
|
|
}
|
|
|
|
type Tx interface {
|
|
Bucket(name []byte) Bucket
|
|
|
|
Commit(ctx context.Context) error
|
|
Rollback() error
|
|
}
|
|
|
|
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)
|
|
Next() ([]byte, []byte, error)
|
|
Walk(walker func(k, v []byte) (bool, error)) error
|
|
}
|
|
|
|
type NoValuesCursor interface {
|
|
First() ([]byte, uint32, error)
|
|
Seek(seek []byte) ([]byte, uint32, error)
|
|
Next() ([]byte, uint32, error)
|
|
Walk(walker func(k []byte, vSize uint32) (bool, error)) error
|
|
}
|
|
|
|
type DbProvider uint8
|
|
|
|
const (
|
|
Bolt DbProvider = iota
|
|
Badger
|
|
Remote
|
|
)
|