db

package
v4.14.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2019 License: Apache-2.0 Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

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

DB is a bbolt key/value database.

func NewDB

func NewDB(filename string) (*DB, error)

NewDB creates/opens a new db.

func (*DB) Begin

func (db *DB) Begin() (TxInterface, error)

Begin implements transactions.Begin.

func (*DB) Close

func (db *DB) Close() error

Close implements transactions.Close.

type Interface

type Interface interface {
	// Begin starts a DB transaction. Apply `defer tx.Rollback()` in any case after. Use
	// `tx.Commit()` to commit the write operations.
	Begin() (TxInterface, error)
	Close() error
}

Interface can be implemented by database backends to open database transactions.

type Tx

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

Tx implements DBTxInterface.

func (*Tx) Commit

func (tx *Tx) Commit() error

Commit implements DBTxInterface.

func (*Tx) OutgoingTransactions

func (tx *Tx) OutgoingTransactions() ([]*types.TransactionWithMetadata, error)

OutgoingTransactions implements DBTxInterface.

func (*Tx) PutOutgoingTransaction

func (tx *Tx) PutOutgoingTransaction(transaction *types.TransactionWithMetadata) error

PutOutgoingTransaction implements DBTxInterface.

func (*Tx) Rollback

func (tx *Tx) Rollback()

Rollback implements DBTxInterface.

type TxInterface

type TxInterface interface {
	// Commit closes the transaction, writing the changes.
	Commit() error

	// Rollback closes the transaction without writing anything and be called safely after Commit().
	Rollback()

	// PutOutgoingTransaction stores the transaction in the collection of outgoing transactions.
	PutOutgoingTransaction(*types.TransactionWithMetadata) error

	// OutgoingTransactions returns the stored list of outgoing transactions, sorted descending by
	// the transaction nonce.
	OutgoingTransactions() ([]*types.TransactionWithMetadata, error)
}

TxInterface needs to be implemented to persist all wallet/transaction related data.

Jump to

Keyboard shortcuts

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