persist

package
v1.1.2-alpha1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: BSD-3-Clause Imports: 16 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) GetBotTransactionIdentifiers

func (txdb *TransactionDB) GetBotTransactionIdentifiers(id types.BotID) (ids []rivinetypes.TransactionID, err error)

GetBotTransactionIdentifiers returns the identifiers of all transactions that created and updated the given bot's record.

The transaction identifiers are returned in the (stable) order as defined by the blockchain.

func (*TransactionDB) GetMintConditionAt

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

GetMintConditionAt implements types.MintConditionGetter.GetMintConditionAt

func (*TransactionDB) GetRecordForID

func (txdb *TransactionDB) GetRecordForID(id types.BotID) (record *types.BotRecord, err error)

GetRecordForID returns the record mapped to the given BotID.

func (*TransactionDB) GetRecordForKey

func (txdb *TransactionDB) GetRecordForKey(key types.PublicKey) (record *types.BotRecord, err error)

GetRecordForKey returns the record mapped to the given Key.

func (*TransactionDB) GetRecordForName

func (txdb *TransactionDB) GetRecordForName(name types.BotName) (record *types.BotRecord, err error)

GetRecordForName returns the record mapped to the given Name.

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).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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