Documentation ¶
Overview ¶
Package utxodb implements UTXO selection and reservation.
Index ¶
- Variables
- type Change
- type DBReserver
- func (res *DBReserver) Cancel(ctx context.Context, rid int32) error
- func (res *DBReserver) ExpireReservations(ctx context.Context) error
- func (res *DBReserver) Reserve(ctx context.Context, source Source, exp time.Time) (reservationID int32, u []*UTXO, c []Change, err error)
- func (res *DBReserver) ReserveUTXO(ctx context.Context, txHash bc.Hash, pos uint32, clientToken *string, ...) (reservationID int32, utxo *UTXO, err error)
- type Source
- type UTXO
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrInsufficient indicates the account doesn't contain enough // units of the requested asset to satisfy the reservation. // New units must be deposited into the account in order to // satisfy the request; change will not be sufficient. ErrInsufficient = errors.New("reservation found insufficient funds") // ErrReserved indicates that a reservation could not be // satisfied because some of the outputs were already reserved. // When those reservations are finalized into a transaction // (and no other transaction spends funds from the account), // new change outputs will be created // in sufficient amounts to satisfy the request. ErrReserved = errors.New("reservation found outputs already reserved") )
Functions ¶
This section is empty.
Types ¶
type Change ¶
Change represents reserved units beyond what was asked for. Total reservation is for Amount+Source.Amount.
type DBReserver ¶
func (*DBReserver) Cancel ¶
func (res *DBReserver) Cancel(ctx context.Context, rid int32) error
Cancel cancels the given reservation if possible. If it doesn't exist (if it's already been consumed or canceled), it is silently ignored.
func (*DBReserver) ExpireReservations ¶
func (res *DBReserver) ExpireReservations(ctx context.Context) error
func (*DBReserver) Reserve ¶
func (res *DBReserver) Reserve(ctx context.Context, source Source, exp time.Time) (reservationID int32, u []*UTXO, c []Change, err error)
Reserve reserves account UTXOs to cover the provided sources. If UTXOs are successfully reserved, it's the responsbility of the caller to cancel them if an error occurs.
Click to show internal directories.
Click to hide internal directories.