db

package
v4.6.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2019 License: Apache-2.0 Imports: 6 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) PendingOutgoingTransactions

func (tx *Tx) PendingOutgoingTransactions() ([]*types.Transaction, error)

PendingOutgoingTransactions implements DBTxInterface.

func (*Tx) PutPendingOutgoingTransaction

func (tx *Tx) PutPendingOutgoingTransaction(transaction *types.Transaction) error

PutPendingOutgoingTransaction 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()

	// PutPendingOutgoingTransaction stores the transaction in the collection of pending outgoing
	// transactions.
	PutPendingOutgoingTransaction(*types.Transaction) error

	// PendingOutgoingTransactions returns the stored list of pending outgoing transactions, sorted
	// descending by the transaction nonce.
	PendingOutgoingTransactions() ([]*types.Transaction, 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