db

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2024 License: BlueOak-1.0.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrNotFound = dex.ErrorKind("not found")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func New

func New(dir string, log dex.Logger) (*DB, error)

func (*DB) GetBonds

func (d *DB) GetBonds(peerID tanka.PeerID) ([]*tanka.Bond, error)

func (*DB) GetPeer

func (d *DB) GetPeer(peerID tanka.PeerID) (_ *tanka.Peer, err error)

func (*DB) RegisterPenalty

func (d *DB) RegisterPenalty(peerID tanka.PeerID, stamp time.Time, penaltyID [32]byte, scoreDecrement uint8, penaltyInfo encoding.BinaryMarshaler) error

func (*DB) RegisterSuccess

func (d *DB) RegisterSuccess(peerID tanka.PeerID, stamp time.Time, refID [32]byte) error

func (*DB) Reputation

func (d *DB) Reputation(peerID tanka.PeerID) (rep *tanka.Reputation, err error)

func (*DB) StoreBond

func (d *DB) StoreBond(newBond *tanka.Bond) (goodBonds []*tanka.Bond, err error)

type IterationOption

type IterationOption struct {
	// contains filtered or unexported fields
}

func WithMaxEntries

func WithMaxEntries(max uint64, deleteExcess bool) *IterationOption

func WithPrefix

func WithPrefix(b []byte) *IterationOption

func WithReverse

func WithReverse() *IterationOption

type KeyValueDB

type KeyValueDB interface {
	Get(k []byte, thing encoding.BinaryUnmarshaler) (bool, error)
	Store(k []byte, thing encoding.BinaryMarshaler) error
	Close() error
	ForEach(f func(k, v []byte) error, opts ...*IterationOption) error
	Run(context.Context)
	Delete(k []byte) error
}

func NewFileDB

func NewFileDB(filePath string, log dex.Logger) (KeyValueDB, error)

func NewMemoryDB

func NewMemoryDB() KeyValueDB

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL