Merge pull request #8102 from filecoin-project/feat/paych-avail-reuse-updated-markets

feat(markets): update markets to simplify client adapter
This commit is contained in:
Łukasz Magiera 2022-02-16 10:01:10 +01:00 committed by GitHub
commit cdca1a46b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 36 deletions

2
go.mod
View File

@ -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

4
go.sum
View File

@ -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=

View File

@ -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)
}