persist

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2018 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TransactionDBDir      = "transactiondb"
	TransactionDBFilename = TransactionDBDir + ".db"
)

TransactionDB I/O constants

Variables

This section is empty.

Functions

This section is empty.

Types

type TransactionDB

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

TransactionDB extends Rivine's ConsensusSet module, allowing us to track transactions (and specifically parts of it) that we care about, and for which Rivine does not implement any logic.

The initial motivation (and currently only use case) is to track MintConditions, as to be able to know for any given block height what the active MintCondition is, but other use cases can be supported in future updates should they appear.

func NewTransactionDB

func NewTransactionDB(rootDir string, genesisMintCondition rivinetypes.UnlockConditionProxy) (*TransactionDB, error)

NewTransactionDB creates a new TransactionDB, using the given file (path) to store the (single) persistent BoltDB file. A new db will be created if it doesn't exist yet, if it does exist it should be ensured that the given genesis mint condition equals the already stored genesis mint condition.

func (*TransactionDB) Close

func (txdb *TransactionDB) Close() error

Close the transaction DB, meaning the db will be unsubscribed from the consensus set, as well the threadgroup will be stopped and the internal bolt db will be closed.

func (*TransactionDB) GetActiveMintCondition

func (txdb *TransactionDB) GetActiveMintCondition() (rivinetypes.UnlockConditionProxy, error)

GetActiveMintCondition implements types.MintConditionGetter.GetActiveMintCondition

func (*TransactionDB) GetMintConditionAt

func (txdb *TransactionDB) GetMintConditionAt(height rivinetypes.BlockHeight) (rivinetypes.UnlockConditionProxy, error)

GetMintConditionAt implements types.MintConditionGetter.GetMintConditionAt

func (*TransactionDB) SubscribeToConsensusSet

func (txdb *TransactionDB) SubscribeToConsensusSet(cs modules.ConsensusSet) error

SubscribeToConsensusSet subscribes the TransactionDB to the given ConsensusSet, allowing it to stay in sync with the blockchain, and also making it automatically unsubscribe from the consensus set when the TransactionDB is closed (using (*TransactionDB).Close).

Jump to

Keyboard shortcuts

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