Documentation ¶
Index ¶
- Variables
- func BestSpendableByLane(ctx context.Context, api BestSpendableAPI, ch address.Address) (map[uint64]*paych.SignedVoucher, error)
- type BestSpendableAPI
- type ErrInsufficientFunds
- type GetOpts
- type IChainInfo
- type IMessagePush
- type IWalletAPI
- type Manager
- func (pm *Manager) AddVoucherInbound(ctx context.Context, ch address.Address, sv *types.SignedVoucher, proof []byte, ...) (big.Int, error)
- func (pm *Manager) AddVoucherOutbound(ctx context.Context, ch address.Address, sv *types.SignedVoucher, proof []byte, ...) (big.Int, error)
- func (pm *Manager) AllocateLane(ctx context.Context, ch address.Address) (uint64, error)
- func (pm *Manager) AvailableFunds(ctx context.Context, ch address.Address) (*types.ChannelAvailableFunds, error)
- func (pm *Manager) AvailableFundsByFromTo(ctx context.Context, from address.Address, to address.Address) (*types.ChannelAvailableFunds, error)
- func (pm *Manager) CheckVoucherSpendable(ctx context.Context, ch address.Address, sv *types.SignedVoucher, ...) (bool, error)
- func (pm *Manager) CheckVoucherValid(ctx context.Context, ch address.Address, sv *types.SignedVoucher) error
- func (pm *Manager) Collect(ctx context.Context, addr address.Address) (cid.Cid, error)
- func (pm *Manager) CreateVoucher(ctx context.Context, ch address.Address, voucher types.SignedVoucher) (*types.VoucherCreateResult, error)
- func (pm *Manager) GetChannelInfo(ctx context.Context, addr address.Address) (*pchTypes.ChannelInfo, error)
- func (pm *Manager) GetPaych(ctx context.Context, from, to address.Address, amt big.Int, opts GetOpts) (address.Address, cid.Cid, error)
- func (pm *Manager) GetPaychWaitReady(ctx context.Context, mcid cid.Cid) (address.Address, error)
- func (pm *Manager) ListChannels(ctx context.Context) ([]address.Address, error)
- func (pm *Manager) ListVouchers(ctx context.Context, ch address.Address) ([]*pchTypes.VoucherInfo, error)
- func (pm *Manager) Settle(ctx context.Context, addr address.Address) (cid.Cid, error)
- func (pm *Manager) Start(ctx context.Context) error
- func (pm *Manager) Stop()
- func (pm *Manager) SubmitVoucher(ctx context.Context, ch address.Address, sv *types.SignedVoucher, ...) (cid.Cid, error)
- type ManagerParams
- type Store
- func (ps *Store) AllocateLane(ctx context.Context, ch address.Address) (uint64, error)
- func (ps *Store) ByAddress(ctx context.Context, addr address.Address) (*pchTypes.ChannelInfo, error)
- func (ps *Store) ByChannelID(ctx context.Context, channelID string) (*pchTypes.ChannelInfo, error)
- func (ps *Store) ByMessageCid(ctx context.Context, mcid cid.Cid) (*pchTypes.ChannelInfo, error)
- func (ps *Store) CreateChannel(ctx context.Context, from address.Address, to address.Address, ...) (*pchTypes.ChannelInfo, error)
- func (ps *Store) GetMessage(ctx context.Context, mcid cid.Cid) (*pchTypes.MsgInfo, error)
- func (ps *Store) ListChannels(ctx context.Context) ([]address.Address, error)
- func (ps *Store) MarkVoucherSubmitted(ctx context.Context, ci *pchTypes.ChannelInfo, sv *paych.SignedVoucher) error
- func (ps *Store) OutboundActiveByFromTo(ctx context.Context, sma managerAPI, from address.Address, to address.Address) (*pchTypes.ChannelInfo, error)
- func (ps *Store) RemoveChannel(ctx context.Context, channelID string) error
- func (ps *Store) SaveMessageResult(ctx context.Context, mcid cid.Cid, msgErr error) error
- func (ps *Store) SaveNewMessage(ctx context.Context, channelID string, mcid cid.Cid) error
- func (ps *Store) TrackChannel(ctx context.Context, ci *pchTypes.ChannelInfo) (*pchTypes.ChannelInfo, error)
- func (ps *Store) VouchersForPaych(ctx context.Context, ch address.Address) ([]*pchTypes.VoucherInfo, error)
- func (ps *Store) WithPendingAddFunds(ctx context.Context) ([]pchTypes.ChannelInfo, error)
Constants ¶
This section is empty.
Variables ¶
var ErrChannelNotTracked = errors.New("channel not tracked")
Functions ¶
func BestSpendableByLane ¶
func BestSpendableByLane(ctx context.Context, api BestSpendableAPI, ch address.Address) (map[uint64]*paych.SignedVoucher, error)
BestSpendableByLane return spendable voucher in channel address
Types ¶
type BestSpendableAPI ¶
type ErrInsufficientFunds ¶
type ErrInsufficientFunds struct {
// contains filtered or unexported fields
}
func (*ErrInsufficientFunds) Error ¶
func (e *ErrInsufficientFunds) Error() string
func (*ErrInsufficientFunds) Shortfall ¶
func (e *ErrInsufficientFunds) Shortfall() big.Int
type IChainInfo ¶ added in v1.1.0
type IChainInfo interface { StateAccountKey(ctx context.Context, addr address.Address, tsk types.TipSetKey) (address.Address, error) StateNetworkVersion(ctx context.Context, tsk types.TipSetKey) (network.Version, error) StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*types.MsgLookup, error) }
type IMessagePush ¶ added in v1.1.0
type IMessagePush interface {
MpoolPushMessage(ctx context.Context, msg *types.Message, spec *types.MessageSendSpec) (*types.SignedMessage, error)
}
type IWalletAPI ¶ added in v1.1.0
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func NewManager(ctx context.Context, ds datastore.Batching, params *ManagerParams) (*Manager, error)
func (*Manager) AddVoucherInbound ¶
func (pm *Manager) AddVoucherInbound(ctx context.Context, ch address.Address, sv *types.SignedVoucher, proof []byte, minDelta big.Int) (big.Int, error)
AddVoucherInbound adds a voucher for an inbound channel. If the channel is not in the store, fetches the channel from state (and checks that the channel To address is owned by the wallet).
func (*Manager) AddVoucherOutbound ¶
func (pm *Manager) AddVoucherOutbound(ctx context.Context, ch address.Address, sv *types.SignedVoucher, proof []byte, minDelta big.Int) (big.Int, error)
AddVoucherOutbound adds a voucher for an outbound channel. Returns an error if the channel is not already in the store.
func (*Manager) AllocateLane ¶
func (*Manager) AvailableFunds ¶
func (*Manager) AvailableFundsByFromTo ¶
func (*Manager) CheckVoucherSpendable ¶
func (pm *Manager) CheckVoucherSpendable(ctx context.Context, ch address.Address, sv *types.SignedVoucher, secret []byte, proof []byte) (bool, error)
CheckVoucherSpendable checks if the given voucher is currently spendable
func (*Manager) CheckVoucherValid ¶
func (pm *Manager) CheckVoucherValid(ctx context.Context, ch address.Address, sv *types.SignedVoucher) error
CheckVoucherValid checks if the given voucher is valid (is or could become spendable at some point). If the channel is not in the store, fetches the channel from state (and checks that the channel To address is owned by the wallet).
func (*Manager) CreateVoucher ¶
func (pm *Manager) CreateVoucher(ctx context.Context, ch address.Address, voucher types.SignedVoucher) (*types.VoucherCreateResult, error)
func (*Manager) GetChannelInfo ¶
func (*Manager) GetPaychWaitReady ¶
GetPaychWaitReady waits until the create channel / add funds message with the given message CID arrives. The returned channel address can safely be used against the Manager methods.
func (*Manager) ListChannels ¶
func (*Manager) ListVouchers ¶
func (*Manager) SubmitVoucher ¶
func (pm *Manager) SubmitVoucher(ctx context.Context, ch address.Address, sv *types.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error)
TODO: secret vs proof doesn't make sense, there is only one, not two
type ManagerParams ¶
type ManagerParams struct { MPoolAPI IMessagePush ChainInfoAPI IChainInfo WalletAPI IWalletAPI SM statemanger.IStateManager }
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) AllocateLane ¶
AllocateLane allocates a new lane for the given channel
func (*Store) ByAddress ¶
func (ps *Store) ByAddress(ctx context.Context, addr address.Address) (*pchTypes.ChannelInfo, error)
ByAddress gets the channel that matches the given address
func (*Store) ByChannelID ¶
ByChannelID gets channel info by channel ID
func (*Store) ByMessageCid ¶
ByMessageCid gets the channel associated with a message
func (*Store) CreateChannel ¶
func (ps *Store) CreateChannel(ctx context.Context, from address.Address, to address.Address, createMsgCid cid.Cid, amt, avail fbig.Int) (*pchTypes.ChannelInfo, error)
CreateChannel creates an outbound channel for the given from / to
func (*Store) GetMessage ¶
GetMessage gets the message info for a given message CID
func (*Store) ListChannels ¶
ListChannels returns the addresses of all channels that have been created
func (*Store) MarkVoucherSubmitted ¶
func (ps *Store) MarkVoucherSubmitted(ctx context.Context, ci *pchTypes.ChannelInfo, sv *paych.SignedVoucher) error
func (*Store) OutboundActiveByFromTo ¶
func (ps *Store) OutboundActiveByFromTo(ctx context.Context, sma managerAPI, from address.Address, to address.Address) (*pchTypes.ChannelInfo, error)
OutboundActiveByFromTo looks for outbound channels that have not been settled, with the given from / to addresses
func (*Store) RemoveChannel ¶
RemoveChannel removes the channel with the given channel ID
func (*Store) SaveMessageResult ¶
SaveMessageResult is called when the result of a message is received
func (*Store) SaveNewMessage ¶
SaveNewMessage is called when a message is sent
func (*Store) TrackChannel ¶
func (ps *Store) TrackChannel(ctx context.Context, ci *pchTypes.ChannelInfo) (*pchTypes.ChannelInfo, error)
TrackChannel stores a channel, returning an error if the channel was already being tracked
func (*Store) VouchersForPaych ¶
func (ps *Store) VouchersForPaych(ctx context.Context, ch address.Address) ([]*pchTypes.VoucherInfo, error)
VouchersForPaych gets the vouchers for the given channel
func (*Store) WithPendingAddFunds ¶
WithPendingAddFunds is used on startup to find channels for which a create channel or add funds message has been sent, but lotus shut down before the response was received.