db

package
v0.0.0-...-d9fe26e Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch interface {
	SetDeleter
	Write()
	WriteSync()
}

type DB

type DB interface {

	// Get returns nil iff key doesn't exist.
	// A nil key is interpreted as an empty byteslice.
	// CONTRACT: key, value readonly []byte
	Get([]byte) []byte

	// Has checks if a key exists.
	// A nil key is interpreted as an empty byteslice.
	// CONTRACT: key, value readonly []byte
	Has(key []byte) bool

	// Set sets the key.
	// A nil key is interpreted as an empty byteslice.
	// CONTRACT: key, value readonly []byte
	Set([]byte, []byte)
	SetSync([]byte, []byte)

	// Delete deletes the key.
	// A nil key is interpreted as an empty byteslice.
	// CONTRACT: key readonly []byte
	Delete([]byte)
	DeleteSync([]byte)

	// Iterate over a domain of keys in ascending order. End is exclusive.
	// Start must be less than end, or the Iterator is invalid.
	// A nil start is interpreted as an empty byteslice.
	// If end is nil, iterates up to the last item (inclusive).
	// CONTRACT: No writes may happen within a domain while an iterator exists over it.
	// CONTRACT: start, end readonly []byte
	Iterator(start, end []byte) Iterator

	// Iterate over a domain of keys in descending order. End is exclusive.
	// Start must be greater than end, or the Iterator is invalid.
	// If start is nil, iterates from the last/greatest item (inclusive).
	// If end is nil, iterates up to the first/least item (inclusive).
	// CONTRACT: No writes may happen within a domain while an iterator exists over it.
	// CONTRACT: start, end readonly []byte
	ReverseIterator(start, end []byte) Iterator

	// Closes the connection.
	Close()

	// Creates a batch for atomic updates.
	NewBatch() Batch

	// For debugging
	Print()

	// Stats returns a map of property values for all keys and the size of the cache.
	Stats() map[string]string
}

DBs are goroutine safe.

type GoLevelDB

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

func NewGoLevelDB

func NewGoLevelDB(name string) (*GoLevelDB, error)

func NewGoLevelDBWithOpts

func NewGoLevelDBWithOpts(name string, o *opt.Options) (*GoLevelDB, error)

func (*GoLevelDB) Close

func (db *GoLevelDB) Close()

Implements DB.

func (*GoLevelDB) DB

func (db *GoLevelDB) DB() *leveldb.DB

func (*GoLevelDB) Delete

func (db *GoLevelDB) Delete(key []byte)

Implements DB.

func (*GoLevelDB) DeleteSync

func (db *GoLevelDB) DeleteSync(key []byte)

Implements DB.

func (*GoLevelDB) Get

func (db *GoLevelDB) Get(key []byte) []byte

Implements DB.

func (*GoLevelDB) Has

func (db *GoLevelDB) Has(key []byte) bool

Implements DB.

func (*GoLevelDB) Iterator

func (db *GoLevelDB) Iterator(start, end []byte) Iterator

Implements DB.

func (*GoLevelDB) NewBatch

func (db *GoLevelDB) NewBatch() Batch

Implements DB.

func (*GoLevelDB) Print

func (db *GoLevelDB) Print()

Implements DB.

func (*GoLevelDB) ReverseIterator

func (db *GoLevelDB) ReverseIterator(start, end []byte) Iterator

Implements DB.

func (*GoLevelDB) Set

func (db *GoLevelDB) Set(key []byte, value []byte)

Implements DB.

func (*GoLevelDB) SetSync

func (db *GoLevelDB) SetSync(key []byte, value []byte)

Implements DB.

func (*GoLevelDB) Stats

func (db *GoLevelDB) Stats() map[string]string

Implements DB.

type Iterator

type Iterator interface {

	// The start & end (exclusive) limits to iterate over.
	// If end < start, then the Iterator goes in reverse order.
	//
	// A domain of ([]byte{12, 13}, []byte{12, 14}) will iterate
	// over anything with the prefix []byte{12, 13}.
	//
	// The smallest key is the empty byte array []byte{} - see BeginningKey().
	// The largest key is the nil byte array []byte(nil) - see EndingKey().
	// CONTRACT: start, end readonly []byte
	Domain() (start []byte, end []byte)

	// Valid returns whether the current position is valid.
	// Once invalid, an Iterator is forever invalid.
	Valid() bool

	// Next moves the iterator to the next sequential key in the database, as
	// defined by order of iteration.
	//
	// If Valid returns false, this method will panic.
	Next()

	// Key returns the key of the cursor.
	// If Valid returns false, this method will panic.
	// CONTRACT: key readonly []byte
	Key() (key []byte)

	// Value returns the value of the cursor.
	// If Valid returns false, this method will panic.
	// CONTRACT: value readonly []byte
	Value() (value []byte)

	// Close releases the Iterator.
	Close()
}

Usage:

var itr Iterator = ... defer itr.Close()

for ; itr.Valid(); itr.Next() {
	k, v := itr.Key(); itr.Value()
	// ...
}

type KeygenStarted

type KeygenStarted struct {
	Started bool
}

type SetDeleter

type SetDeleter interface {
	Set(key, value []byte) // CONTRACT: key, value readonly []byte
	Delete(key []byte)     // CONTRACT: key readonly []byte
}

type SqliteDB

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

Store represents persistent customer and event storage.

func NewSqliteDB

func NewSqliteDB(path string) (*SqliteDB, error)

New returns a new sql database.

func (*SqliteDB) Get

func (s *SqliteDB) Get(key int64) (int64, error)

func (*SqliteDB) Set

func (s *SqliteDB) Set(key, val int64) error

type TorusLDB

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

TorusLDB implements TorusDB on top of LevelDB

func NewTorusLDB

func NewTorusLDB(dbDirPath string) (*TorusLDB, error)

NewTorusLDB returns a leveldb implementation of TorusDB NOTE: dbDirPath MUST be a directory

func (*TorusLDB) GetKeygenStarted

func (t *TorusLDB) GetKeygenStarted(keygenID string) bool

func (*TorusLDB) GetShareCount

func (t *TorusLDB) GetShareCount() int

func (*TorusLDB) KeyIndexToPublicKeyExists

func (t *TorusLDB) KeyIndexToPublicKeyExists(keyIndex big.Int) bool

func (*TorusLDB) RetrieveCommitmentMatrix

func (t *TorusLDB) RetrieveCommitmentMatrix(keyIndex big.Int) ([][]common.Point, error)

func (*TorusLDB) RetrieveCompletedShare

func (t *TorusLDB) RetrieveCompletedShare(keyIndex big.Int) (*big.Int, *big.Int, error)

func (*TorusLDB) RetrieveConnectionDetails

func (t *TorusLDB) RetrieveConnectionDetails(nodeAddress ethCommon.Address) (tmP2PConnection string, p2pConnection string, err error)

func (*TorusLDB) RetrieveKeyIndexToPublicKey

func (t *TorusLDB) RetrieveKeyIndexToPublicKey(keyIndex big.Int) (*common.Point, error)

func (*TorusLDB) RetrieveNodePubKey

func (t *TorusLDB) RetrieveNodePubKey(nodeAddress ethCommon.Address) (pubKey common.Point, err error)

func (*TorusLDB) RetrievePublicKeyToKeyIndex

func (t *TorusLDB) RetrievePublicKeyToKeyIndex(publicKey common.Point) (*big.Int, error)

func (*TorusLDB) SetKeygenStarted

func (t *TorusLDB) SetKeygenStarted(keygenID string, started bool)

func (*TorusLDB) StoreCompletedKeygenShare

func (t *TorusLDB) StoreCompletedKeygenShare(keyIndex big.Int, si big.Int, siprime big.Int) error

func (*TorusLDB) StoreCompletedPSSShare

func (t *TorusLDB) StoreCompletedPSSShare(keyIndex big.Int, si big.Int, siprime big.Int) error

func (*TorusLDB) StoreConnectionDetails

func (t *TorusLDB) StoreConnectionDetails(nodeAddress ethCommon.Address, tmP2PConnection string, p2pConnection string) error

func (*TorusLDB) StoreKeygenCommitmentMatrix

func (t *TorusLDB) StoreKeygenCommitmentMatrix(keyIndex big.Int, c [][]common.Point) error

func (*TorusLDB) StoreNodePubKey

func (t *TorusLDB) StoreNodePubKey(nodeAddress ethCommon.Address, pubKey common.Point) error

func (*TorusLDB) StorePSSCommitmentMatrix

func (t *TorusLDB) StorePSSCommitmentMatrix(keyIndex big.Int, c [][]common.Point) error

func (*TorusLDB) StorePublicKeyToKeyIndex

func (t *TorusLDB) StorePublicKeyToKeyIndex(publicKey common.Point, keyIndex big.Int) error

Jump to

Keyboard shortcuts

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