utxo

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TransactionFeeKey is the LevelDB key used to store the transaction fee of the most
	// recent signed transaction.
	// TODO: trailing "-" should be removed, will this cause issues with active bifrosts?
	TransactionFeeKey = "transactionfee-"

	// PrefixBlockMeta is the LevelDB key prefix used for storing BlockMeta. The height of
	// the block is appended for the final key.
	PrefixBlockMeta = "blockmeta-"

	// PrefixMempool is the LevelDB key prefix used for storing transactions in the
	// mempool. The hash of the transaction is appended for the final key.
	PrefixMempool = "mempool-"

	// PrefixObservedTx is the LevelDB key prefix used for storing observed transactions.
	// The hash of the transaction is appended for the final key.
	PrefixObservedTx = "observed-"
)

Variables

This section is empty.

Functions

func GetAsgardAddress

func GetAsgardAddress(chain common.Chain, maxAsgardAddresses int, bridge ddclient.DdchainBridge) ([]common.Address, error)

func PostKeysignFailure

func PostKeysignFailure(
	ddchainBridge ddclient.DdchainBridge,
	tx stypes.TxOutItem,
	logger zerolog.Logger,
	ddchainHeight int64,
	utxoErr error,
) error

Types

type BlockMeta

type BlockMeta struct {
	Height       int64  `json:"height"`
	PreviousHash string `json:"previous_hash"`
	BlockHash    string `json:"block_hash"`

	// SelfTransactions records txids that our vaults have broadcast.
	SelfTransactions []string `json:"self_transactions,omitempty"`

	// CustomerTransactions records txids that our vaults have received.
	CustomerTransactions []string `json:"customer_transactions,omitempty"`
}

BlockMeta contains a subset of meta information about a block relevant to Bifrost's book keeping of pending operations.

func NewBlockMeta

func NewBlockMeta(previousHash string, height int64, blockHash string) *BlockMeta

func (*BlockMeta) AddCustomerTransaction

func (b *BlockMeta) AddCustomerTransaction(txid string)

AddCustomerTransaction adds the provided txid to the BlockMeta customer transactions.

func (*BlockMeta) AddSelfTransaction

func (b *BlockMeta) AddSelfTransaction(txid string)

AddSelfTransaction adds the provided txid to the BlockMeta self transactions.

func (*BlockMeta) RemoveCustomerTransaction

func (b *BlockMeta) RemoveCustomerTransaction(txid string)

RemoveCustomerTransaction removes the provided txid from the BlockMeta customer transactions.

func (*BlockMeta) TransactionHashExists

func (b *BlockMeta) TransactionHashExists(hash string) bool

TransactionHashExist returns true if the txid exists in either the self or customer transactions for the BlockMeta.

type PruneBlockMetaFunc

type PruneBlockMetaFunc func(meta *BlockMeta) bool

PruneBlockMetaFunc defines a function type that is used to prune blocks from temporal storage. The function should return true if the block is eligible for pruning.

type SignCheckpoint

type SignCheckpoint struct {
	UnsignedTx        []byte           `json:"unsigned_tx"`
	IndividualAmounts map[string]int64 `json:"individual_amounts"`
}

SignCheckpoint is used to checkpoint the built transaction before signing, for use in round 7 signing errors which must reuse the same inputs.

type TemporalStorage

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

TemporalStorage provides persistent storage of block and transaction data over a window of recent time. This is used to track transactions we have sent, during re-org processing, and to ensure duplicate observations are not posted to Ddchain which could result in bond slash.

func NewTemporalStorage

func NewTemporalStorage(db *leveldb.DB, txidCacheSize int) (*TemporalStorage, error)

func (*TemporalStorage) GetBlockMeta

func (t *TemporalStorage) GetBlockMeta(height int64) (*BlockMeta, error)

GetBlockMeta returns the BlockMeta at the provided height. Note that if the BlockMeta for the requested height is not found, we will return nil with nil error.

func (*TemporalStorage) GetBlockMetas

func (t *TemporalStorage) GetBlockMetas() ([]*BlockMeta, error)

GetBlockMetas returns all the block metas in storage.

func (*TemporalStorage) GetTransactionFee

func (t *TemporalStorage) GetTransactionFee() (float64, int32, error)

GetTransactionFee returns the last transaction fee written to storage.

func (*TemporalStorage) PruneBlockMeta

func (t *TemporalStorage) PruneBlockMeta(height int64, filter PruneBlockMetaFunc) error

PruneBlockMeta removes all BlockMetas that are older than the provided block height and pass the provided filter function. Consumers should provide a function for the filter to ensure there are no transactions in the mempool corresponding to the block.

func (*TemporalStorage) SaveBlockMeta

func (t *TemporalStorage) SaveBlockMeta(height int64, blockMeta *BlockMeta) error

SaveBlockMeta will store the provided BlockMeta at the provided height.

func (*TemporalStorage) TrackMempoolTx

func (t *TemporalStorage) TrackMempoolTx(txid string) (bool, error)

TrackMempoolTx attempts to track the provided mempool txid. Returns true if the txid was successfully added, and false if the txid was already tracked or an error occurred during write.

func (*TemporalStorage) TrackObservedTx

func (t *TemporalStorage) TrackObservedTx(txid string) (bool, error)

TrackObservedTx attempts to track the provided observed txid. Returns true if the txid was successfully added, and false if the txid was already tracked or an error occurred during write.

func (*TemporalStorage) UntrackMempoolTx

func (t *TemporalStorage) UntrackMempoolTx(txid string) error

UntrackMempoolTx untracks the provided mempool txid.

func (*TemporalStorage) UntrackObservedTx

func (t *TemporalStorage) UntrackObservedTx(txid string) error

UntrackObservedTx untracks the provided observed txid.

func (*TemporalStorage) UpsertTransactionFee

func (t *TemporalStorage) UpsertTransactionFee(fee float64, vSize int32) error

UpsertTransactionFee sets the latest transaction fee, overwriting any existing value.

type TransactionFee

type TransactionFee struct {
	// Fee is the transaction fee in the chain asset.
	Fee float64 `json:"fee"`

	// VSize is the estimated vbytes of the transaction. On chains with no concept of
	// transaction weight, this is simply the estimated byte size of the transaction.
	VSize int32 `json:"v_size"`
}

TransactionFee represents the transaction fee on a UTXO chain.

Jump to

Keyboard shortcuts

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