persist

package
v1.1.2-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2019 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) GetERC20AddressForTFTAddress

func (txdb *TransactionDB) GetERC20AddressForTFTAddress(uh rivinetypes.UnlockHash) (addr types.ERC20Address, found bool, err error)

GetERC20AddressForTFTAddress returns the mapped ERC20 address for the given TFT Address, iff the TFT Address has registered an ERC20 address explicitly.

func (*TransactionDB) GetLastConsensusChangeID

func (txdb *TransactionDB) GetLastConsensusChangeID() modules.ConsensusChangeID

Retrieves the Last ConsensusChangeID stored.

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

func (txdb *TransactionDB) GetTFTAddressForERC20Address(addr types.ERC20Address) (uh rivinetypes.UnlockHash, found bool, err error)

GetTFTAddressForERC20Address returns the mapped TFT address for the given ERC20 Address, iff the TFT Address has registered an ERC20 address explicitly.

func (*TransactionDB) GetTFTTransactionIDForERC20TransactionID

func (txdb *TransactionDB) GetTFTTransactionIDForERC20TransactionID(id types.ERC20Hash) (txid rivinetypes.TransactionID, found bool, err error)

GetTFTTransactionIDForERC20TransactionID returns the mapped TFT TransactionID for the given ERC20 TransactionID, iff the ERC20 TransactionID has been used to fund an ERC20 CoinCreation Tx and has been registered as such, a nil TransactionID is returned otherwise.

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