market

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2021 License: Apache-2.0, MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FundManager

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

FundManager keeps track of funds in a set of addresses

func NewFundManager

func NewFundManager(lc fx.Lifecycle, api FundManagerAPI, ds dtypes.MetadataDS) *FundManager

func (*FundManager) GetReserved

func (fm *FundManager) GetReserved(addr address.Address) abi.TokenAmount

GetReserved returns the amount that is currently reserved for the address

func (*FundManager) Release

func (fm *FundManager) Release(addr address.Address, amt abi.TokenAmount) error

Subtract from `reserved`.

func (*FundManager) Reserve

func (fm *FundManager) Reserve(ctx context.Context, wallet, addr address.Address, amt abi.TokenAmount) (cid.Cid, error)

Reserve adds amt to `reserved`. If there are not enough available funds for the address, submits a message on chain to top up available funds. Returns the cid of the message that was submitted on chain, or cid.Undef if the required funds were already available.

func (*FundManager) Start

func (fm *FundManager) Start() error

func (*FundManager) Stop

func (fm *FundManager) Stop()

func (*FundManager) Withdraw

func (fm *FundManager) Withdraw(ctx context.Context, wallet, addr address.Address, amt abi.TokenAmount) (cid.Cid, error)

Withdraw unreserved funds. Only succeeds if there are enough unreserved funds for the address. Returns the cid of the message that was submitted on chain.

type FundManagerAPI

type FundManagerAPI struct {
	fx.In

	full.StateAPI
	full.MpoolAPI
}

API is the fx dependencies need to run a fund manager

type FundedAddressState

type FundedAddressState struct {
	Addr address.Address
	// AmtReserved is the amount that must be kept in the address (cannot be
	// withdrawn)
	AmtReserved abi.TokenAmount
	// MsgCid is the cid of an in-progress on-chain message
	MsgCid *cid.Cid
}

FundedAddressState keeps track of the state of an address with funds in the datastore

func (*FundedAddressState) MarshalCBOR

func (t *FundedAddressState) MarshalCBOR(w io.Writer) error

func (*FundedAddressState) UnmarshalCBOR

func (t *FundedAddressState) UnmarshalCBOR(r io.Reader) error

type Store

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

Jump to

Keyboard shortcuts

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