heavy

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// HeaderPrefix is the prefix to identify the Header.
	HeaderPrefix = []byte{0x01}
	// TxPrefix is the prefix to identify Transactions.
	TxPrefix = []byte{0x02}
	// HeightPrefix is the prefix to identify the Height.
	HeightPrefix = []byte{0x03}
	// TxIDPrefix is the prefix to identify the Transaction ID.
	TxIDPrefix = []byte{0x04}
	// KeyImagePrefix is the prefix to identify the Key Image.
	KeyImagePrefix = []byte{0x05}
	// StatePrefix is the prefix to identify the State.
	StatePrefix = []byte{0x06}
	// OutputKeyPrefix is the prefix to identify the Output.
	OutputKeyPrefix = []byte{0x07}
	// BidValuesPrefix is the prefix to identify Bid Values.
	BidValuesPrefix = []byte{0x08}
	// CandidatePrefix is the prefix to identify Candidate messages.
	CandidatePrefix = []byte{0x09}
)
View Source
var BidEncodingSize = 72

BidEncodingSize is the expected size of the serialized encoding of the bid.

View Source
var DriverName = "heavy_v0.1.0"

DriverName is the unique identifier for the heavy driver.

Functions

func CreateDBConnection

func CreateDBConnection() (database.Driver, database.DB)

CreateDBConnection creates a connection with the DB using the `heavy` driver.

func NewDatabase

func NewDatabase(path string, network protocol.Magic, readonly bool) (database.DB, error)

NewDatabase create or open backend storage (goleveldb) located at the specified path. Readonly option is pseudo read-only mode implemented by heavy.Database. Not to be confused with read-only goleveldb mode.

Types

type DB

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

DB on top of underlying storage syndtr/goleveldb/leveldb.

func (DB) Begin

func (db DB) Begin(writable bool) (database.Transaction, error)

Begin builds read-only or read-write Transaction.

func (DB) Close

func (db DB) Close() error

Close does not close the underlying storage as we need to reuse it within another DB instances. Note that we rely on the Finalizer that goleveldb is setting at the point of leveldb.DB.openDB to call leveldb.DB.Close() when the process is terminating.

func (DB) GetSnapshot

func (db DB) GetSnapshot() (*leveldb.Snapshot, error)

GetSnapshot returns current storage snapshot. To be used only by database/testing pkg.

func (DB) Update

func (db DB) Update(fn func(database.Transaction) error) error

Update a record within a transaction.

func (DB) View

func (db DB) View(fn func(database.Transaction) error) error

View is the equivalent of a Select SQL statement.

Jump to

Keyboard shortcuts

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