2020-07-28 23:16:47 +00:00
|
|
|
package paychmgr
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2020-09-30 16:35:42 +00:00
|
|
|
"errors"
|
2020-07-28 23:16:47 +00:00
|
|
|
"sync"
|
|
|
|
|
|
|
|
"github.com/ipfs/go-cid"
|
2020-09-16 04:06:04 +00:00
|
|
|
"github.com/ipfs/go-datastore"
|
2020-07-28 23:16:47 +00:00
|
|
|
logging "github.com/ipfs/go-log/v2"
|
2020-09-16 04:06:04 +00:00
|
|
|
xerrors "golang.org/x/xerrors"
|
2020-07-28 23:16:47 +00:00
|
|
|
|
|
|
|
"github.com/filecoin-project/go-address"
|
2021-04-05 17:56:53 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/abi"
|
2020-09-16 04:06:04 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/crypto"
|
2020-09-30 17:04:10 +00:00
|
|
|
"github.com/filecoin-project/go-state-types/network"
|
2020-07-28 23:16:47 +00:00
|
|
|
|
2020-09-16 04:06:04 +00:00
|
|
|
"github.com/filecoin-project/lotus/api"
|
|
|
|
"github.com/filecoin-project/lotus/chain/actors/builtin/paych"
|
2020-07-28 23:16:47 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/stmgr"
|
|
|
|
"github.com/filecoin-project/lotus/chain/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
var log = logging.Logger("paych")
|
|
|
|
|
2020-09-30 16:35:42 +00:00
|
|
|
var errProofNotSupported = errors.New("payment channel proof parameter is not supported")
|
|
|
|
|
2020-08-11 14:20:05 +00:00
|
|
|
// stateManagerAPI defines the methods needed from StateManager
|
|
|
|
type stateManagerAPI interface {
|
2020-09-16 04:06:04 +00:00
|
|
|
ResolveToKeyAddress(ctx context.Context, addr address.Address, ts *types.TipSet) (address.Address, error)
|
|
|
|
GetPaychState(ctx context.Context, addr address.Address, ts *types.TipSet) (*types.Actor, paych.State, error)
|
2020-07-28 23:16:47 +00:00
|
|
|
Call(ctx context.Context, msg *types.Message, ts *types.TipSet) (*api.InvocResult, error)
|
|
|
|
}
|
|
|
|
|
2020-08-11 14:20:05 +00:00
|
|
|
// paychAPI defines the API methods needed by the payment channel manager
|
2021-03-12 08:39:20 +00:00
|
|
|
type PaychAPI interface {
|
2020-08-19 22:56:51 +00:00
|
|
|
StateAccountKey(context.Context, address.Address, types.TipSetKey) (address.Address, error)
|
2021-04-05 17:56:53 +00:00
|
|
|
StateWaitMsg(ctx context.Context, cid cid.Cid, confidence uint64, limit abi.ChainEpoch, allowReplaced bool) (*api.MsgLookup, error)
|
2020-08-12 20:17:21 +00:00
|
|
|
MpoolPushMessage(ctx context.Context, msg *types.Message, maxFee *api.MessageSendSpec) (*types.SignedMessage, error)
|
2020-08-17 15:13:13 +00:00
|
|
|
WalletHas(ctx context.Context, addr address.Address) (bool, error)
|
2020-09-01 14:33:44 +00:00
|
|
|
WalletSign(ctx context.Context, k address.Address, msg []byte) (*crypto.Signature, error)
|
2020-09-30 17:04:10 +00:00
|
|
|
StateNetworkVersion(context.Context, types.TipSetKey) (network.Version, error)
|
2020-08-11 14:20:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// managerAPI defines all methods needed by the manager
|
|
|
|
type managerAPI interface {
|
|
|
|
stateManagerAPI
|
2021-03-12 08:39:20 +00:00
|
|
|
PaychAPI
|
2020-08-11 14:20:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// managerAPIImpl is used to create a composite that implements managerAPI
|
|
|
|
type managerAPIImpl struct {
|
2020-10-09 11:41:09 +00:00
|
|
|
stmgr.StateManagerAPI
|
2021-03-12 08:39:20 +00:00
|
|
|
PaychAPI
|
2020-08-11 14:20:05 +00:00
|
|
|
}
|
|
|
|
|
2020-07-28 23:16:47 +00:00
|
|
|
type Manager struct {
|
|
|
|
// The Manager context is used to terminate wait operations on shutdown
|
|
|
|
ctx context.Context
|
|
|
|
shutdown context.CancelFunc
|
|
|
|
|
|
|
|
store *Store
|
|
|
|
sa *stateAccessor
|
2020-08-11 14:20:05 +00:00
|
|
|
pchapi managerAPI
|
2020-07-28 23:16:47 +00:00
|
|
|
|
|
|
|
lk sync.RWMutex
|
|
|
|
channels map[string]*channelAccessor
|
|
|
|
}
|
|
|
|
|
2021-03-12 01:35:31 +00:00
|
|
|
func NewManager(ctx context.Context, shutdown func(), sm stmgr.StateManagerAPI, pchstore *Store, api PaychAPI) *Manager {
|
2021-03-12 08:39:20 +00:00
|
|
|
impl := &managerAPIImpl{StateManagerAPI: sm, PaychAPI: api}
|
2020-07-28 23:16:47 +00:00
|
|
|
return &Manager{
|
2020-08-05 20:47:06 +00:00
|
|
|
ctx: ctx,
|
|
|
|
shutdown: shutdown,
|
2020-07-28 23:16:47 +00:00
|
|
|
store: pchstore,
|
2020-08-11 14:20:05 +00:00
|
|
|
sa: &stateAccessor{sm: impl},
|
2020-07-28 23:16:47 +00:00
|
|
|
channels: make(map[string]*channelAccessor),
|
2020-08-11 14:20:05 +00:00
|
|
|
pchapi: impl,
|
2020-07-28 23:16:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// newManager is used by the tests to supply mocks
|
2020-08-11 14:20:05 +00:00
|
|
|
func newManager(pchstore *Store, pchapi managerAPI) (*Manager, error) {
|
2020-07-28 23:16:47 +00:00
|
|
|
pm := &Manager{
|
|
|
|
store: pchstore,
|
2020-08-11 14:20:05 +00:00
|
|
|
sa: &stateAccessor{sm: pchapi},
|
2020-07-28 23:16:47 +00:00
|
|
|
channels: make(map[string]*channelAccessor),
|
|
|
|
pchapi: pchapi,
|
|
|
|
}
|
2020-08-05 20:47:06 +00:00
|
|
|
return pm, pm.Start()
|
2020-07-28 23:16:47 +00:00
|
|
|
}
|
|
|
|
|
2020-08-06 12:47:48 +00:00
|
|
|
// Start restarts tracking of any messages that were sent to chain.
|
2020-08-05 20:47:06 +00:00
|
|
|
func (pm *Manager) Start() error {
|
2021-12-11 21:03:00 +00:00
|
|
|
return pm.restartPending(pm.ctx)
|
2020-07-28 23:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Stop shuts down any processes used by the manager
|
|
|
|
func (pm *Manager) Stop() error {
|
|
|
|
pm.shutdown()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-01-04 19:33:49 +00:00
|
|
|
func (pm *Manager) GetPaych(ctx context.Context, from, to address.Address, amt types.BigInt, reserve bool) (address.Address, cid.Cid, error) {
|
2020-07-28 23:16:47 +00:00
|
|
|
chanAccessor, err := pm.accessorByFromTo(from, to)
|
|
|
|
if err != nil {
|
|
|
|
return address.Undef, cid.Undef, err
|
|
|
|
}
|
|
|
|
|
2022-01-04 19:33:49 +00:00
|
|
|
return chanAccessor.getPaych(ctx, amt, reserve)
|
2020-07-28 23:16:47 +00:00
|
|
|
}
|
|
|
|
|
2021-12-11 21:03:00 +00:00
|
|
|
func (pm *Manager) AvailableFunds(ctx context.Context, ch address.Address) (*api.ChannelAvailableFunds, error) {
|
|
|
|
ca, err := pm.accessorByAddress(ctx, ch)
|
2020-09-04 11:44:09 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-12-11 21:03:00 +00:00
|
|
|
ci, err := ca.getChannelInfo(ctx, ch)
|
2020-09-04 11:44:09 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-12-11 21:03:00 +00:00
|
|
|
return ca.availableFunds(ctx, ci.ChannelID)
|
2020-09-04 11:44:09 +00:00
|
|
|
}
|
|
|
|
|
2021-12-11 21:03:00 +00:00
|
|
|
func (pm *Manager) AvailableFundsByFromTo(ctx context.Context, from address.Address, to address.Address) (*api.ChannelAvailableFunds, error) {
|
2020-09-04 11:44:09 +00:00
|
|
|
ca, err := pm.accessorByFromTo(from, to)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-12-11 21:03:00 +00:00
|
|
|
ci, err := ca.outboundActiveByFromTo(ctx, from, to)
|
2020-09-04 11:44:09 +00:00
|
|
|
if err == ErrChannelNotTracked {
|
|
|
|
// If there is no active channel between from / to we still want to
|
|
|
|
// return an empty ChannelAvailableFunds, so that clients can check
|
|
|
|
// for the existence of a channel between from / to without getting
|
|
|
|
// an error.
|
|
|
|
return &api.ChannelAvailableFunds{
|
|
|
|
Channel: nil,
|
|
|
|
From: from,
|
|
|
|
To: to,
|
|
|
|
ConfirmedAmt: types.NewInt(0),
|
|
|
|
PendingAmt: types.NewInt(0),
|
2022-01-04 22:20:11 +00:00
|
|
|
AvailableAmt: types.NewInt(0),
|
|
|
|
PendingAvailableAmt: types.NewInt(0),
|
2020-09-04 11:44:09 +00:00
|
|
|
PendingWaitSentinel: nil,
|
|
|
|
QueuedAmt: types.NewInt(0),
|
|
|
|
VoucherReedeemedAmt: types.NewInt(0),
|
|
|
|
}, nil
|
|
|
|
}
|
2020-09-01 14:33:44 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2021-12-11 21:03:00 +00:00
|
|
|
return ca.availableFunds(ctx, ci.ChannelID)
|
2020-09-01 14:33:44 +00:00
|
|
|
}
|
|
|
|
|
2020-07-28 23:16:47 +00:00
|
|
|
// 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 (pm *Manager) GetPaychWaitReady(ctx context.Context, mcid cid.Cid) (address.Address, error) {
|
|
|
|
// Find the channel associated with the message CID
|
2020-08-05 21:51:55 +00:00
|
|
|
pm.lk.Lock()
|
2021-12-11 21:03:00 +00:00
|
|
|
ci, err := pm.store.ByMessageCid(ctx, mcid)
|
2020-08-05 21:51:55 +00:00
|
|
|
pm.lk.Unlock()
|
|
|
|
|
2020-07-28 23:16:47 +00:00
|
|
|
if err != nil {
|
|
|
|
if err == datastore.ErrNotFound {
|
|
|
|
return address.Undef, xerrors.Errorf("Could not find wait msg cid %s", mcid)
|
|
|
|
}
|
|
|
|
return address.Undef, err
|
|
|
|
}
|
|
|
|
|
|
|
|
chanAccessor, err := pm.accessorByFromTo(ci.Control, ci.Target)
|
|
|
|
if err != nil {
|
|
|
|
return address.Undef, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return chanAccessor.getPaychWaitReady(ctx, mcid)
|
|
|
|
}
|
|
|
|
|
2021-12-11 21:03:00 +00:00
|
|
|
func (pm *Manager) ListChannels(ctx context.Context) ([]address.Address, error) {
|
2020-07-28 23:16:47 +00:00
|
|
|
// Need to take an exclusive lock here so that channel operations can't run
|
|
|
|
// in parallel (see channelLock)
|
|
|
|
pm.lk.Lock()
|
|
|
|
defer pm.lk.Unlock()
|
|
|
|
|
2021-12-11 21:03:00 +00:00
|
|
|
return pm.store.ListChannels(ctx)
|
2020-07-28 23:16:47 +00:00
|
|
|
}
|
|
|
|
|
2021-12-11 21:03:00 +00:00
|
|
|
func (pm *Manager) GetChannelInfo(ctx context.Context, addr address.Address) (*ChannelInfo, error) {
|
|
|
|
ca, err := pm.accessorByAddress(ctx, addr)
|
2020-07-28 23:16:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-12-11 21:03:00 +00:00
|
|
|
return ca.getChannelInfo(ctx, addr)
|
2020-07-28 23:16:47 +00:00
|
|
|
}
|
|
|
|
|
2020-09-28 21:25:58 +00:00
|
|
|
func (pm *Manager) CreateVoucher(ctx context.Context, ch address.Address, voucher paych.SignedVoucher) (*api.VoucherCreateResult, error) {
|
2021-12-11 21:03:00 +00:00
|
|
|
ca, err := pm.accessorByAddress(ctx, ch)
|
2020-09-01 14:33:44 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return ca.createVoucher(ctx, ch, voucher)
|
|
|
|
}
|
|
|
|
|
2020-08-19 13:16:54 +00:00
|
|
|
// 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).
|
2020-09-28 21:25:58 +00:00
|
|
|
func (pm *Manager) CheckVoucherValid(ctx context.Context, ch address.Address, sv *paych.SignedVoucher) error {
|
2020-08-19 13:16:54 +00:00
|
|
|
// Get an accessor for the channel, creating it from state if necessary
|
|
|
|
ca, err := pm.inboundChannelAccessor(ctx, ch)
|
2020-07-28 23:16:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = ca.checkVoucherValid(ctx, ch, sv)
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// CheckVoucherSpendable checks if the given voucher is currently spendable
|
2020-09-28 21:25:58 +00:00
|
|
|
func (pm *Manager) CheckVoucherSpendable(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (bool, error) {
|
2020-09-30 16:35:42 +00:00
|
|
|
if len(proof) > 0 {
|
|
|
|
return false, errProofNotSupported
|
|
|
|
}
|
2021-12-11 21:03:00 +00:00
|
|
|
ca, err := pm.accessorByAddress(ctx, ch)
|
2020-07-28 23:16:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
|
2020-09-30 16:35:42 +00:00
|
|
|
return ca.checkVoucherSpendable(ctx, ch, sv, secret)
|
2020-07-28 23:16:47 +00:00
|
|
|
}
|
|
|
|
|
2020-08-17 15:13:13 +00:00
|
|
|
// AddVoucherOutbound adds a voucher for an outbound channel.
|
|
|
|
// Returns an error if the channel is not already in the store.
|
2020-09-28 21:25:58 +00:00
|
|
|
func (pm *Manager) AddVoucherOutbound(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error) {
|
2020-09-30 16:35:42 +00:00
|
|
|
if len(proof) > 0 {
|
|
|
|
return types.NewInt(0), errProofNotSupported
|
|
|
|
}
|
2021-12-11 21:03:00 +00:00
|
|
|
ca, err := pm.accessorByAddress(ctx, ch)
|
2020-07-28 23:16:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return types.NewInt(0), err
|
|
|
|
}
|
2020-09-30 16:35:42 +00:00
|
|
|
return ca.addVoucher(ctx, ch, sv, minDelta)
|
2020-07-28 23:16:47 +00:00
|
|
|
}
|
|
|
|
|
2020-08-17 15:13:13 +00:00
|
|
|
// 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).
|
2020-09-28 21:25:58 +00:00
|
|
|
func (pm *Manager) AddVoucherInbound(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, proof []byte, minDelta types.BigInt) (types.BigInt, error) {
|
2020-09-30 16:35:42 +00:00
|
|
|
if len(proof) > 0 {
|
|
|
|
return types.NewInt(0), errProofNotSupported
|
|
|
|
}
|
2020-08-19 13:16:54 +00:00
|
|
|
// Get an accessor for the channel, creating it from state if necessary
|
|
|
|
ca, err := pm.inboundChannelAccessor(ctx, ch)
|
|
|
|
if err != nil {
|
|
|
|
return types.BigInt{}, err
|
|
|
|
}
|
2020-09-30 16:35:42 +00:00
|
|
|
return ca.addVoucher(ctx, ch, sv, minDelta)
|
2020-08-19 13:16:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// inboundChannelAccessor gets an accessor for the given channel. The channel
|
|
|
|
// must either exist in the store, or be an inbound channel that can be created
|
|
|
|
// from state.
|
|
|
|
func (pm *Manager) inboundChannelAccessor(ctx context.Context, ch address.Address) (*channelAccessor, error) {
|
2020-08-17 15:13:13 +00:00
|
|
|
// Make sure channel is in store, or can be fetched from state, and that
|
|
|
|
// the channel To address is owned by the wallet
|
|
|
|
ci, err := pm.trackInboundChannel(ctx, ch)
|
|
|
|
if err != nil {
|
2020-08-19 13:16:54 +00:00
|
|
|
return nil, err
|
2020-08-17 15:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This is an inbound channel, so To is the Control address (this node)
|
|
|
|
from := ci.Target
|
|
|
|
to := ci.Control
|
2020-08-19 13:16:54 +00:00
|
|
|
return pm.accessorByFromTo(from, to)
|
2020-08-17 15:13:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (pm *Manager) trackInboundChannel(ctx context.Context, ch address.Address) (*ChannelInfo, error) {
|
|
|
|
// Need to take an exclusive lock here so that channel operations can't run
|
|
|
|
// in parallel (see channelLock)
|
|
|
|
pm.lk.Lock()
|
|
|
|
defer pm.lk.Unlock()
|
|
|
|
|
|
|
|
// Check if channel is in store
|
2021-12-11 21:03:00 +00:00
|
|
|
ci, err := pm.store.ByAddress(ctx, ch)
|
2020-08-17 15:13:13 +00:00
|
|
|
if err == nil {
|
|
|
|
// Channel is in store, so it's already being tracked
|
|
|
|
return ci, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there's an error (besides channel not in store) return err
|
|
|
|
if err != ErrChannelNotTracked {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Channel is not in store, so get channel from state
|
|
|
|
stateCi, err := pm.sa.loadStateChannelInfo(ctx, ch, DirInbound)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check that channel To address is in wallet
|
|
|
|
to := stateCi.Control // Inbound channel so To addr is Control (this node)
|
2020-08-19 22:56:51 +00:00
|
|
|
toKey, err := pm.pchapi.StateAccountKey(ctx, to, types.EmptyTSK)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
has, err := pm.pchapi.WalletHas(ctx, toKey)
|
2020-08-17 15:13:13 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if !has {
|
|
|
|
msg := "cannot add voucher for channel %s: wallet does not have key for address %s"
|
|
|
|
return nil, xerrors.Errorf(msg, ch, to)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Save channel to store
|
2021-12-11 21:03:00 +00:00
|
|
|
return pm.store.TrackChannel(ctx, stateCi)
|
2020-08-17 15:13:13 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 12:56:08 +00:00
|
|
|
// TODO: secret vs proof doesn't make sense, there is only one, not two
|
2020-09-28 21:25:58 +00:00
|
|
|
func (pm *Manager) SubmitVoucher(ctx context.Context, ch address.Address, sv *paych.SignedVoucher, secret []byte, proof []byte) (cid.Cid, error) {
|
2020-09-30 16:35:42 +00:00
|
|
|
if len(proof) > 0 {
|
|
|
|
return cid.Undef, errProofNotSupported
|
|
|
|
}
|
2021-12-11 21:03:00 +00:00
|
|
|
ca, err := pm.accessorByAddress(ctx, ch)
|
2020-08-20 16:09:52 +00:00
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, err
|
|
|
|
}
|
2020-09-30 16:35:42 +00:00
|
|
|
return ca.submitVoucher(ctx, ch, sv, secret)
|
2020-08-20 16:09:52 +00:00
|
|
|
}
|
|
|
|
|
2021-12-11 21:03:00 +00:00
|
|
|
func (pm *Manager) AllocateLane(ctx context.Context, ch address.Address) (uint64, error) {
|
|
|
|
ca, err := pm.accessorByAddress(ctx, ch)
|
2020-07-28 23:16:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return 0, err
|
|
|
|
}
|
2021-12-11 21:03:00 +00:00
|
|
|
return ca.allocateLane(ctx, ch)
|
2020-07-28 23:16:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (pm *Manager) ListVouchers(ctx context.Context, ch address.Address) ([]*VoucherInfo, error) {
|
2021-12-11 21:03:00 +00:00
|
|
|
ca, err := pm.accessorByAddress(ctx, ch)
|
2020-07-28 23:16:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return ca.listVouchers(ctx, ch)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (pm *Manager) Settle(ctx context.Context, addr address.Address) (cid.Cid, error) {
|
2021-12-11 21:03:00 +00:00
|
|
|
ca, err := pm.accessorByAddress(ctx, addr)
|
2020-07-28 23:16:47 +00:00
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, err
|
|
|
|
}
|
|
|
|
return ca.settle(ctx, addr)
|
|
|
|
}
|
2020-08-10 17:21:25 +00:00
|
|
|
|
|
|
|
func (pm *Manager) Collect(ctx context.Context, addr address.Address) (cid.Cid, error) {
|
2021-12-11 21:03:00 +00:00
|
|
|
ca, err := pm.accessorByAddress(ctx, addr)
|
2020-08-10 17:21:25 +00:00
|
|
|
if err != nil {
|
|
|
|
return cid.Undef, err
|
|
|
|
}
|
|
|
|
return ca.collect(ctx, addr)
|
|
|
|
}
|