Documentation ¶
Index ¶
- Variables
- func ExtractPrice(ctx context.Context, price string) (*big.Int, *big.Int, error)
- type TxAction
- type TxActionType
- type TxHop
- type TxPlan
- func (p *TxPlan) Check(ctx context.Context, transaction *mint.TransactionResource, hop int8) error
- func (p *TxPlan) CheckCanCancel(ctx context.Context, client *mint.Client, hop int8) bool
- func (p *TxPlan) CheckShouldCancel(ctx context.Context, client *mint.Client, hop int8) bool
- func (p *TxPlan) MinMaxHop(ctx context.Context) (*int8, *int8, error)
Constants ¶
This section is empty.
Variables ¶
var PriceRegexp = regexp.MustCompile(
"^([0-9]+)\\/([0-9]+)$")
PriceRegexp is used to validate and parse a transaction price.
Functions ¶
Types ¶
type TxAction ¶
type TxAction struct { Owner string Type TxActionType Amount *big.Int CrossingOffer *string OperationAsset *string OperationSource *string OperationDestination *string }
TxAction represents an action to be performed by a mint. Either an operation or crossing creation.
type TxActionType ¶
type TxActionType string
TxActionType is the type of the action of a TxPlan
const ( // TxActTpOperation is the action type for an operation creation. TxActTpOperation TxActionType = "operation" // TxActTpCrossing is the action type for a crossing creation. TxActTpCrossing TxActionType = "crossing" )
type TxHop ¶
TxHop is a list of action to be performed by the mint at the associated hop. hop 0 is the mint creating the transaction, hop (i) is the mint on the offer path at index (i-1).
type TxPlan ¶
TxPlan is the plan associated with the transaction. It is constructed by each mint involved in the transaction. Each hop represents a mint along the offer path starting with the mint initiating the transaction.
func Compute ¶
func Compute( ctx context.Context, client *mint.Client, tx *model.Transaction, shallow bool, ) (*TxPlan, error)
Compute retrieves the offers of the path and compute the transaction plan.
func (*TxPlan) Check ¶
func (p *TxPlan) Check( ctx context.Context, transaction *mint.TransactionResource, hop int8, ) error
Check checks that the plan was properly executed at the specified hop by retrieving the transaction ont that mint and checking the actions against the advertised operations and crossings.
func (*TxPlan) CheckCanCancel ¶
CheckCanCancel checks that this node is authorized to cancel the transaction (this is the node with higher hop or the node above it has already canceled the transaction). Works on a shallow plan.
func (*TxPlan) CheckShouldCancel ¶
CheckShouldCancel checks whether the next node on the offer path has canceled. If so, no need to settle, we can cancel instead. Works on a shallow plan.