feat(markets): update for new paych logic
Update adapter to use wait methods provided by paych adapter
This commit is contained in:
parent
45d9ddc79f
commit
b048fcd7c1
@ -1,21 +1,16 @@
|
||||
package retrievaladapter
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-fil-markets/retrievalmarket"
|
||||
"github.com/filecoin-project/go-fil-markets/shared"
|
||||
"github.com/filecoin-project/specs-actors/actors/abi"
|
||||
initactor "github.com/filecoin-project/specs-actors/actors/builtin/init"
|
||||
"github.com/filecoin-project/specs-actors/actors/builtin/paych"
|
||||
"github.com/filecoin-project/specs-actors/actors/runtime/exitcode"
|
||||
"github.com/ipfs/go-cid"
|
||||
"github.com/multiformats/go-multiaddr"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/node/impl/full"
|
||||
payapi "github.com/filecoin-project/lotus/node/impl/paych"
|
||||
@ -76,31 +71,12 @@ func (rcn *retrievalClientNode) GetChainHead(ctx context.Context) (shared.TipSet
|
||||
// WaitForPaymentChannelAddFunds waits messageCID to appear on chain. If it doesn't appear within
|
||||
// defaultMsgWaitTimeout it returns error
|
||||
func (rcn *retrievalClientNode) WaitForPaymentChannelAddFunds(messageCID cid.Cid) error {
|
||||
_, mr, err := rcn.chainAPI.StateManager.WaitForMessage(context.TODO(), messageCID, build.MessageConfidence)
|
||||
|
||||
if err != nil {
|
||||
_, err := rcn.payAPI.PaychMgr.GetPaychWaitReady(context.TODO(), messageCID)
|
||||
return err
|
||||
}
|
||||
if mr.ExitCode != exitcode.Ok {
|
||||
return xerrors.Errorf("wait for payment channel to add funds failed. exit code: %d", mr.ExitCode)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (rcn *retrievalClientNode) WaitForPaymentChannelCreation(messageCID cid.Cid) (address.Address, error) {
|
||||
_, mr, err := rcn.chainAPI.StateManager.WaitForMessage(context.TODO(), messageCID, build.MessageConfidence)
|
||||
|
||||
if err != nil {
|
||||
return address.Undef, err
|
||||
}
|
||||
if mr.ExitCode != exitcode.Ok {
|
||||
return address.Undef, xerrors.Errorf("payment channel creation failed. exit code: %d", mr.ExitCode)
|
||||
}
|
||||
var retval initactor.ExecReturn
|
||||
if err := retval.UnmarshalCBOR(bytes.NewReader(mr.Return)); err != nil {
|
||||
return address.Undef, err
|
||||
}
|
||||
return retval.RobustAddress, nil
|
||||
return rcn.payAPI.PaychMgr.GetPaychWaitReady(context.TODO(), messageCID)
|
||||
}
|
||||
|
||||
func (rcn *retrievalClientNode) GetKnownAddresses(ctx context.Context, p retrievalmarket.RetrievalPeer, encodedTs shared.TipSetToken) ([]multiaddr.Multiaddr, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user