From e1a36058b44089ce1da97f3a85eaf07491057cf8 Mon Sep 17 00:00:00 2001 From: hannahhoward Date: Tue, 15 Feb 2022 21:52:06 -0800 Subject: [PATCH] feat(markets): update markets to simplify client adapter --- go.mod | 2 +- go.sum | 4 ++-- markets/retrievaladapter/client.go | 33 ------------------------------ 3 files changed, 3 insertions(+), 36 deletions(-) diff --git a/go.mod b/go.mod index f22400ded..6b6191de6 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/filecoin-project/go-data-transfer v1.14.0 github.com/filecoin-project/go-fil-commcid v0.1.0 github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 - github.com/filecoin-project/go-fil-markets v1.19.0 + github.com/filecoin-project/go-fil-markets v1.19.1 github.com/filecoin-project/go-jsonrpc v0.1.5 github.com/filecoin-project/go-padreader v0.0.1 github.com/filecoin-project/go-paramfetch v0.0.4 diff --git a/go.sum b/go.sum index 6b725b5df..3df9f4eb0 100644 --- a/go.sum +++ b/go.sum @@ -327,8 +327,8 @@ github.com/filecoin-project/go-fil-commcid v0.1.0 h1:3R4ds1A9r6cr8mvZBfMYxTS88Oq github.com/filecoin-project/go-fil-commcid v0.1.0/go.mod h1:Eaox7Hvus1JgPrL5+M3+h7aSPHc0cVqpSxA+TxIEpZQ= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0 h1:imrrpZWEHRnNqqv0tN7LXep5bFEVOVmQWHJvl2mgsGo= github.com/filecoin-project/go-fil-commp-hashhash v0.1.0/go.mod h1:73S8WSEWh9vr0fDJVnKADhfIv/d6dCbAGaAGWbdJEI8= -github.com/filecoin-project/go-fil-markets v1.19.0 h1:kap2q2wTM6tfkVO5gMA5DD9GUeTvkDhMfhjCtEwMDM8= -github.com/filecoin-project/go-fil-markets v1.19.0/go.mod h1:qsb3apmo4RSJYCEq40QxVdU7UZospN6nFJLOBHuaIbc= +github.com/filecoin-project/go-fil-markets v1.19.1 h1:o5sziAp8zCsvIg3KYMgIpwm8gyOl4MDzEKEf0Qq5L3U= +github.com/filecoin-project/go-fil-markets v1.19.1/go.mod h1:qsb3apmo4RSJYCEq40QxVdU7UZospN6nFJLOBHuaIbc= github.com/filecoin-project/go-hamt-ipld v0.1.5 h1:uoXrKbCQZ49OHpsTCkrThPNelC4W3LPEk0OrS/ytIBM= github.com/filecoin-project/go-hamt-ipld v0.1.5/go.mod h1:6Is+ONR5Cd5R6XZoCse1CWaXZc0Hdb/JeX+EQCQzX24= github.com/filecoin-project/go-hamt-ipld/v2 v2.0.0 h1:b3UDemBYN2HNfk3KOXNuxgTTxlWi3xVvbQP0IT38fvM= diff --git a/markets/retrievaladapter/client.go b/markets/retrievaladapter/client.go index b5535bcfc..74f02570b 100644 --- a/markets/retrievaladapter/client.go +++ b/markets/retrievaladapter/client.go @@ -9,8 +9,6 @@ import ( "github.com/filecoin-project/go-state-types/abi" "github.com/ipfs/go-cid" "github.com/multiformats/go-multiaddr" - mh "github.com/multiformats/go-multihash" - "golang.org/x/xerrors" "github.com/filecoin-project/lotus/api" "github.com/filecoin-project/lotus/chain/actors/builtin/paych" @@ -19,27 +17,6 @@ import ( payapi "github.com/filecoin-project/lotus/node/impl/paych" ) -func mkPaychReusedCid(addr address.Address) cid.Cid { - c, err := cid.V1Builder{Codec: cid.Raw, MhType: mh.IDENTITY}.Sum(addr.Bytes()) - if err != nil { - panic(err) - } - return c -} - -func extractPaychReusedCid(c cid.Cid) (address.Address, error) { - if c.Prefix().Codec != cid.Raw { - return address.Undef, nil - } - - h, err := mh.Decode(c.Hash()) - if err != nil { - return address.Address{}, err - } - - return address.NewFromBytes(h.Digest) -} - type retrievalClientNode struct { forceOffChain bool @@ -72,9 +49,6 @@ func (rcn *retrievalClientNode) GetOrCreatePaymentChannel(ctx context.Context, c log.Errorw("paych get failed", "error", err) return address.Undef, cid.Undef, err } - if ci.WaitSentinel == cid.Undef { - return ci.Channel, mkPaychReusedCid(ci.Channel), nil - } return ci.Channel, ci.WaitSentinel, nil } @@ -112,13 +86,6 @@ func (rcn *retrievalClientNode) GetChainHead(ctx context.Context) (shared.TipSet } func (rcn *retrievalClientNode) WaitForPaymentChannelReady(ctx context.Context, messageCID cid.Cid) (address.Address, error) { - maybeAddr, err := extractPaychReusedCid(messageCID) - if err != nil { - return address.Address{}, xerrors.Errorf("extract paych reused CID: %w", err) - } - if maybeAddr != address.Undef { - return maybeAddr, nil - } return rcn.payAPI.PaychGetWaitReady(ctx, messageCID) }