Documentation ¶
Overview ¶
Package utxodb provides tools to simulate an in-memory synchronous ledger, for testing purposes.
Index ¶
- Constants
- type InitParams
- type UnixSeconds
- type UtxoDB
- func (u *UtxoDB) AddToLedger(tx *iotago.Transaction) error
- func (u *UtxoDB) AdvanceClockBy(step time.Duration)
- func (u *UtxoDB) GenesisAddress() iotago.Address
- func (u *UtxoDB) GetAddressBalanceBaseTokens(addr iotago.Address) uint64
- func (u *UtxoDB) GetAddressBalances(addr iotago.Address) *isc.Assets
- func (u *UtxoDB) GetAddressNFTs(addr iotago.Address) map[iotago.OutputID]*iotago.NFTOutput
- func (u *UtxoDB) GetAliasOutputs(addr iotago.Address) map[iotago.OutputID]*iotago.AliasOutput
- func (u *UtxoDB) GetFundsFromFaucet(target iotago.Address, amount ...uint64) (*iotago.Transaction, error)
- func (u *UtxoDB) GetOutput(outID iotago.OutputID) iotago.Output
- func (u *UtxoDB) GetTransaction(txID iotago.TransactionID) (*iotago.Transaction, bool)
- func (u *UtxoDB) GetUnspentOutputs(addr iotago.Address) (iotago.OutputSet, iotago.OutputIDs)
- func (u *UtxoDB) GlobalTime() time.Time
- func (u *UtxoDB) MustGetTransaction(txID iotago.TransactionID) *iotago.Transaction
- func (u *UtxoDB) SetState(state *UtxoDBState)
- func (u *UtxoDB) State() *UtxoDBState
- func (u *UtxoDB) Supply() uint64
- func (u *UtxoDB) TimeStep() time.Duration
- type UtxoDBState
Constants ¶
const ( DefaultBaseTokenSupply = tpkg.TestTokenSupply // FundsFromFaucetAmount is how many base tokens are returned from the faucet. FundsFromFaucetAmount = 1000 * isc.Million )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InitParams ¶
type InitParams struct {
// contains filtered or unexported fields
}
func DefaultInitParams ¶
func DefaultInitParams() *InitParams
func (*InitParams) WithInitialTime ¶
func (i *InitParams) WithInitialTime(t time.Time) *InitParams
func (*InitParams) WithSupply ¶
func (i *InitParams) WithSupply(supply uint64) *InitParams
func (*InitParams) WithTimeStep ¶
func (i *InitParams) WithTimeStep(timestep time.Duration) *InitParams
type UnixSeconds ¶
type UnixSeconds uint64
type UtxoDB ¶
type UtxoDB struct {
// contains filtered or unexported fields
}
UtxoDB mocks the Tangle ledger by implementing a fully synchronous in-memory database of transactions. It ensures the consistency of the ledger and all added transactions by checking inputs, outputs and signatures.
func (*UtxoDB) AddToLedger ¶
func (u *UtxoDB) AddToLedger(tx *iotago.Transaction) error
AddToLedger adds a transaction to UtxoDB, ensuring consistency of the UtxoDB ledger.
func (*UtxoDB) AdvanceClockBy ¶
func (*UtxoDB) GenesisAddress ¶
GenesisAddress returns the genesis address.
func (*UtxoDB) GetAddressBalanceBaseTokens ¶
GetAddressBalanceBaseTokens returns the total amount of base token owned by the address
func (*UtxoDB) GetAddressBalances ¶
GetAddressBalances returns the total amount of base tokens and tokens owned by the address
func (*UtxoDB) GetAddressNFTs ¶
func (*UtxoDB) GetAliasOutputs ¶
GetAliasOutputs collects all outputs of type iotago.AliasOutput for the address
func (*UtxoDB) GetFundsFromFaucet ¶
func (u *UtxoDB) GetFundsFromFaucet(target iotago.Address, amount ...uint64) (*iotago.Transaction, error)
GetFundsFromFaucet sends FundsFromFaucetAmount base tokens from the genesis address to the given address.
func (*UtxoDB) GetTransaction ¶
func (u *UtxoDB) GetTransaction(txID iotago.TransactionID) (*iotago.Transaction, bool)
GetTransaction retrieves value transaction by its hash (ID).
func (*UtxoDB) GetUnspentOutputs ¶
GetUnspentOutputs returns all unspent outputs locked by the address with its ids
func (*UtxoDB) GlobalTime ¶
func (*UtxoDB) MustGetTransaction ¶
func (u *UtxoDB) MustGetTransaction(txID iotago.TransactionID) *iotago.Transaction
MustGetTransaction same as GetTransaction only panics if transaction is not in UtxoDB.
func (*UtxoDB) SetState ¶
func (u *UtxoDB) SetState(state *UtxoDBState)
func (*UtxoDB) State ¶
func (u *UtxoDB) State() *UtxoDBState