coinlock

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: BlueOak-1.0.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AssetCoinLocker

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

AssetCoinLocker is a coin locker for a single asset. Do not use this for more than one asset.

func NewAssetCoinLocker

func NewAssetCoinLocker() *AssetCoinLocker

NewAssetCoinLocker constructs a new AssetCoinLocker.

func (*AssetCoinLocker) CoinLocked

func (ac *AssetCoinLocker) CoinLocked(coin CoinID) bool

CoinLocked indicates if a coin identifier (e.g. UTXO) is locked.

func (*AssetCoinLocker) LockCoins

func (ac *AssetCoinLocker) LockCoins(orderCoins map[order.OrderID][]CoinID) (failed map[order.OrderID][]CoinID)

LockCoins locks all coins (e.g. UTXOS) connected with certain orders.

func (*AssetCoinLocker) LockOrdersCoins

func (ac *AssetCoinLocker) LockOrdersCoins(orders []order.Order) (failed []order.Order)

LockOrdersCoins locks all coins associated with certain orders.

func (*AssetCoinLocker) OrderCoinsLocked

func (ac *AssetCoinLocker) OrderCoinsLocked(oid order.OrderID) []CoinID

OrderCoinsLocked lists the coin IDs (e.g. UTXOs) locked by an order.

func (*AssetCoinLocker) UnlockAll

func (ac *AssetCoinLocker) UnlockAll()

UnlockAll releases all locked coins.

func (*AssetCoinLocker) UnlockOrderCoins

func (ac *AssetCoinLocker) UnlockOrderCoins(oid order.OrderID)

UnlockOrderCoins unlocks any coins backing the order.

func (*AssetCoinLocker) UnlockOrdersCoins

func (ac *AssetCoinLocker) UnlockOrdersCoins(oids []order.OrderID)

UnlockOrdersCoins unlocks any coins backing the orders.

type CoinID

type CoinID = order.CoinID

type CoinLockChecker

type CoinLockChecker interface {
	// CoinLocked indicates if a coin is locked.
	CoinLocked(coin CoinID) bool
	// OrderCoinsLocked returns all coins locked by an order.
	OrderCoinsLocked(oid order.OrderID) []CoinID
}

CoinLockChecker provides the ability to check if a coin or an order's backing coins are locked.

type CoinLocker

type CoinLocker interface {
	CoinLockChecker
	// UnlockAll releases all locked coins.
	UnlockAll()
	// UnlockOrderCoins unlocks all locked coins associated with an order.
	UnlockOrderCoins(oid order.OrderID)
	// UnlockOrdersCoins is like UnlockOrderCoins for multiple orders.
	UnlockOrdersCoins(oids []order.OrderID)
	// LockOrdersCoins locks all of the coins associated with multiple orders.
	LockOrdersCoins(orders []order.Order) (failed []order.Order)
	// LockCoins locks coins associated with certain orders. The input is
	// defined as a map of OrderIDs to a CoinID slice since it is likely easiest
	// for the caller to construct the input in this way.
	LockCoins(orderCoins map[order.OrderID][]CoinID) (failed map[order.OrderID][]CoinID)
}

CoinLocker provides the ability to lock, unlock and check lock status of coins.

type DEXCoinLocker

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

DEXCoinLocker manages multiple MasterCoinLocker, one for each asset used by the DEX.

func NewDEXCoinLocker

func NewDEXCoinLocker(assets []uint32) *DEXCoinLocker

NewDEXCoinLocker creates a new DEXCoinLocker for the given assets.

func (*DEXCoinLocker) AssetLocker

func (c *DEXCoinLocker) AssetLocker(asset uint32) *MasterCoinLocker

AssetLocker retrieves the MasterCoinLocker for an asset.

func (*DEXCoinLocker) CoinLocked

func (c *DEXCoinLocker) CoinLocked(asset uint32, coin string) bool

CoinLocked checks if a coin belonging to an asset is locked.

func (*DEXCoinLocker) OrderCoinsLocked

func (c *DEXCoinLocker) OrderCoinsLocked(asset uint32, oid order.OrderID) []CoinID

OrderCoinsLocked retrieves all locked coins for a given asset and user.

type MasterCoinLocker

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

MasterCoinLocker coordinates a book and swap coin locker. The lock status of a coin may be checked, and the locker for the book and swapper may be obtained via the Book and Swap methods.

func NewMasterCoinLocker

func NewMasterCoinLocker() *MasterCoinLocker

NewMasterCoinLocker creates a new NewMasterCoinLocker.

func (*MasterCoinLocker) Book

func (cl *MasterCoinLocker) Book() CoinLocker

Book provides the market-level CoinLocker.

func (*MasterCoinLocker) CoinLocked

func (cl *MasterCoinLocker) CoinLocked(coin CoinID) bool

CoinLocked indicates if a coin is locked by either the swap or book lock.

func (*MasterCoinLocker) OrderCoinsLocked

func (cl *MasterCoinLocker) OrderCoinsLocked(oid order.OrderID) []CoinID

OrderCoinsLocked lists all coins locked by a given order are locked by either the swap or book lock.

func (*MasterCoinLocker) Swap

func (cl *MasterCoinLocker) Swap() CoinLocker

Swap provides the swap-level CoinLocker.

Jump to

Keyboard shortcuts

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