cborrpc -> cborutil
This commit is contained in:
parent
58472afa3a
commit
3fbe0abb75
@ -15,7 +15,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
|
||||
blocks "github.com/ipfs/go-block-format"
|
||||
@ -93,7 +93,7 @@ func (bss *BlockSyncService) HandleStream(s inet.Stream) {
|
||||
defer s.Close()
|
||||
|
||||
var req BlockSyncRequest
|
||||
if err := cborrpc.ReadCborRPC(bufio.NewReader(s), &req); err != nil {
|
||||
if err := cborutil.ReadCborRPC(bufio.NewReader(s), &req); err != nil {
|
||||
log.Errorf("failed to read block sync request: %s", err)
|
||||
return
|
||||
}
|
||||
@ -105,7 +105,7 @@ func (bss *BlockSyncService) HandleStream(s inet.Stream) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := cborrpc.WriteCborRPC(s, resp); err != nil {
|
||||
if err := cborutil.WriteCborRPC(s, resp); err != nil {
|
||||
log.Error("failed to write back response for handle stream: ", err)
|
||||
return
|
||||
}
|
||||
@ -401,12 +401,12 @@ func (bs *BlockSync) sendRequestToPeer(ctx context.Context, p peer.ID, req *Bloc
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err := cborrpc.WriteCborRPC(s, req); err != nil {
|
||||
if err := cborutil.WriteCborRPC(s, req); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var res BlockSyncResponse
|
||||
if err := cborrpc.ReadCborRPC(bufio.NewReader(s), &res); err != nil {
|
||||
if err := cborutil.ReadCborRPC(bufio.NewReader(s), &res); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/chain/wallet"
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/retrieval/discovery"
|
||||
)
|
||||
@ -233,7 +233,7 @@ func (c *Client) Start(ctx context.Context, p ClientDealProposal) (cid.Cid, erro
|
||||
return cid.Undef, xerrors.Errorf("signing deal proposal failed: %w", err)
|
||||
}
|
||||
|
||||
proposalNd, err := cborrpc.AsIpld(dealProposal)
|
||||
proposalNd, err := cborutil.AsIpld(dealProposal)
|
||||
if err != nil {
|
||||
return cid.Undef, xerrors.Errorf("getting proposal node failed: %w", err)
|
||||
}
|
||||
@ -248,7 +248,7 @@ func (c *Client) Start(ctx context.Context, p ClientDealProposal) (cid.Cid, erro
|
||||
Piece: p.Data,
|
||||
}
|
||||
|
||||
if err := cborrpc.WriteCborRPC(s, proposal); err != nil {
|
||||
if err := cborutil.WriteCborRPC(s, proposal); err != nil {
|
||||
s.Reset()
|
||||
return cid.Undef, xerrors.Errorf("sending proposal to storage provider failed: %w", err)
|
||||
}
|
||||
@ -280,12 +280,12 @@ func (c *Client) QueryAsk(ctx context.Context, p peer.ID, a address.Address) (*t
|
||||
req := &AskRequest{
|
||||
Miner: a,
|
||||
}
|
||||
if err := cborrpc.WriteCborRPC(s, req); err != nil {
|
||||
if err := cborutil.WriteCborRPC(s, req); err != nil {
|
||||
return nil, xerrors.Errorf("failed to send ask request: %w", err)
|
||||
}
|
||||
|
||||
var out AskResponse
|
||||
if err := cborrpc.ReadCborRPC(s, &out); err != nil {
|
||||
if err := cborutil.ReadCborRPC(s, &out); err != nil {
|
||||
return nil, xerrors.Errorf("failed to read ask response: %w", err)
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
@ -91,7 +91,7 @@ func (c *Client) accepted(ctx context.Context, deal ClientDeal) (func(*ClientDea
|
||||
dealIdx := -1
|
||||
for i, storageDeal := range params.Deals {
|
||||
// TODO: make it less hacky
|
||||
eq, err := cborrpc.Equals(&deal.Proposal, &storageDeal.Proposal)
|
||||
eq, err := cborutil.Equals(&deal.Proposal, &storageDeal.Proposal)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
unixfile "github.com/ipfs/go-unixfs/file"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
"github.com/filecoin-project/lotus/lib/padreader"
|
||||
"github.com/filecoin-project/lotus/lib/sectorbuilder"
|
||||
)
|
||||
@ -72,7 +72,7 @@ func (c *Client) readStorageDealResp(deal ClientDeal) (*Response, error) {
|
||||
}
|
||||
|
||||
var resp SignedResponse
|
||||
if err := cborrpc.ReadCborRPC(s, &resp); err != nil {
|
||||
if err := cborutil.ReadCborRPC(s, &resp); err != nil {
|
||||
log.Errorw("failed to read Response message", "error", err)
|
||||
return nil, err
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/address"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
"github.com/filecoin-project/lotus/lib/statestore"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
"github.com/filecoin-project/lotus/storage"
|
||||
@ -193,7 +193,7 @@ func (p *Provider) onUpdated(ctx context.Context, update minerDealUpdate) {
|
||||
}
|
||||
|
||||
func (p *Provider) newDeal(s inet.Stream, proposal Proposal) (MinerDeal, error) {
|
||||
proposalNd, err := cborrpc.AsIpld(proposal.DealProposal)
|
||||
proposalNd, err := cborutil.AsIpld(proposal.DealProposal)
|
||||
if err != nil {
|
||||
return MinerDeal{}, err
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/address"
|
||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
datastore "github.com/ipfs/go-datastore"
|
||||
inet "github.com/libp2p/go-libp2p-core/network"
|
||||
"golang.org/x/xerrors"
|
||||
@ -54,14 +54,14 @@ func (p *Provider) getAsk(m address.Address) *types.SignedStorageAsk {
|
||||
func (p *Provider) HandleAskStream(s inet.Stream) {
|
||||
defer s.Close()
|
||||
var ar AskRequest
|
||||
if err := cborrpc.ReadCborRPC(s, &ar); err != nil {
|
||||
if err := cborutil.ReadCborRPC(s, &ar); err != nil {
|
||||
log.Errorf("failed to read AskRequest from incoming stream: %s", err)
|
||||
return
|
||||
}
|
||||
|
||||
resp := p.processAskRequest(&ar)
|
||||
|
||||
if err := cborrpc.WriteCborRPC(s, resp); err != nil {
|
||||
if err := cborutil.WriteCborRPC(s, resp); err != nil {
|
||||
log.Errorf("failed to write ask response: %s", err)
|
||||
return
|
||||
}
|
||||
@ -98,7 +98,7 @@ func (p *Provider) loadAsk() error {
|
||||
}
|
||||
|
||||
var ssa types.SignedStorageAsk
|
||||
if err := cborrpc.ReadCborRPC(bytes.NewReader(askb), &ssa); err != nil {
|
||||
if err := cborutil.ReadCborRPC(bytes.NewReader(askb), &ssa); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ func (p *Provider) loadAsk() error {
|
||||
}
|
||||
|
||||
func (p *Provider) signAsk(a *types.StorageAsk) (*types.SignedStorageAsk, error) {
|
||||
b, err := cborrpc.Dump(a)
|
||||
b, err := cborutil.Dump(a)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -129,7 +129,7 @@ func (p *Provider) signAsk(a *types.StorageAsk) (*types.SignedStorageAsk, error)
|
||||
}
|
||||
|
||||
func (p *Provider) saveAsk(a *types.SignedStorageAsk) error {
|
||||
b, err := cborrpc.Dump(a)
|
||||
b, err := cborutil.Dump(a)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -150,7 +150,7 @@ func (c *Client) checkAskSignature(ask *types.SignedStorageAsk) error {
|
||||
return xerrors.Errorf("failed to get worker for miner in ask", err)
|
||||
}
|
||||
|
||||
sigb, err := cborrpc.Dump(ask.Ask)
|
||||
sigb, err := cborutil.Dump(ask.Ask)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to re-serialize ask")
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/address"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
|
||||
"github.com/ipfs/go-cid"
|
||||
inet "github.com/libp2p/go-libp2p-core/network"
|
||||
@ -45,7 +45,7 @@ func (p *Provider) failDeal(id cid.Cid, cerr error) {
|
||||
}
|
||||
|
||||
func (p *Provider) readProposal(s inet.Stream) (proposal Proposal, err error) {
|
||||
if err := cborrpc.ReadCborRPC(s, &proposal); err != nil {
|
||||
if err := cborutil.ReadCborRPC(s, &proposal); err != nil {
|
||||
log.Errorw("failed to read proposal message", "error", err)
|
||||
return proposal, err
|
||||
}
|
||||
@ -68,7 +68,7 @@ func (p *Provider) sendSignedResponse(resp *Response) error {
|
||||
return xerrors.New("couldn't send response: not connected")
|
||||
}
|
||||
|
||||
msg, err := cborrpc.Dump(resp)
|
||||
msg, err := cborutil.Dump(resp)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("serializing response: %w", err)
|
||||
}
|
||||
@ -88,7 +88,7 @@ func (p *Provider) sendSignedResponse(resp *Response) error {
|
||||
Signature: sig,
|
||||
}
|
||||
|
||||
err = cborrpc.WriteCborRPC(s, signedResponse)
|
||||
err = cborutil.WriteCborRPC(s, signedResponse)
|
||||
if err != nil {
|
||||
// Assume client disconnected
|
||||
s.Close()
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/address"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
"github.com/ipfs/go-cid"
|
||||
)
|
||||
|
||||
@ -38,7 +38,7 @@ type SignedResponse struct {
|
||||
}
|
||||
|
||||
func (r *SignedResponse) Verify(addr address.Address) error {
|
||||
b, err := cborrpc.Dump(&r.Response)
|
||||
b, err := cborutil.Dump(&r.Response)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"encoding/base64"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/address"
|
||||
cborrpc "github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
cborrpc "github.com/filecoin-project/lotus/lib/cborutil"
|
||||
cbor "github.com/ipfs/go-ipld-cbor"
|
||||
)
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package cborrpc
|
||||
package cborutil
|
||||
|
||||
import (
|
||||
"bytes"
|
@ -10,7 +10,7 @@ import (
|
||||
cbg "github.com/whyrusleeping/cbor-gen"
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
)
|
||||
|
||||
type StateStore struct {
|
||||
@ -42,7 +42,7 @@ func (st *StateStore) Begin(i interface{}, state interface{}) error {
|
||||
return xerrors.Errorf("Already tracking state for %s", i)
|
||||
}
|
||||
|
||||
b, err := cborrpc.Dump(state)
|
||||
b, err := cborutil.Dump(state)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -68,7 +68,7 @@ func cborMutator(mutator interface{}) func([]byte) ([]byte, error) {
|
||||
return func(in []byte) ([]byte, error) {
|
||||
state := reflect.New(rmut.Type().In(0).Elem())
|
||||
|
||||
err := cborrpc.ReadCborRPC(bytes.NewReader(in), state.Interface())
|
||||
err := cborutil.ReadCborRPC(bytes.NewReader(in), state.Interface())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -79,7 +79,7 @@ func cborMutator(mutator interface{}) func([]byte) ([]byte, error) {
|
||||
return nil, err.(error)
|
||||
}
|
||||
|
||||
return cborrpc.Dump(state.Interface())
|
||||
return cborutil.Dump(state.Interface())
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ func (st *StateStore) List(out interface{}) error {
|
||||
}
|
||||
|
||||
elem := reflect.New(outT)
|
||||
err := cborrpc.ReadCborRPC(bytes.NewReader(res.Value), elem.Interface())
|
||||
err := cborutil.ReadCborRPC(bytes.NewReader(res.Value), elem.Interface())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -6,13 +6,13 @@ import (
|
||||
"github.com/ipfs/go-datastore"
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
)
|
||||
|
||||
func TestList(t *testing.T) {
|
||||
ds := datastore.NewMapDatastore()
|
||||
|
||||
e, err := cborrpc.Dump(types.NewInt(7))
|
||||
e, err := cborutil.Dump(types.NewInt(7))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/chain"
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
"github.com/filecoin-project/lotus/peermgr"
|
||||
)
|
||||
|
||||
@ -66,7 +66,7 @@ func (hs *Service) HandleStream(s inet.Stream) {
|
||||
defer s.Close()
|
||||
|
||||
var hmsg Message
|
||||
if err := cborrpc.ReadCborRPC(s, &hmsg); err != nil {
|
||||
if err := cborutil.ReadCborRPC(s, &hmsg); err != nil {
|
||||
log.Infow("failed to read hello message", "error", err)
|
||||
return
|
||||
}
|
||||
@ -120,7 +120,7 @@ func (hs *Service) SayHello(ctx context.Context, pid peer.ID) error {
|
||||
fmt.Println("SENDING HELLO MESSAGE: ", hts.Cids(), hts.Height())
|
||||
fmt.Println("hello message genesis: ", gen.Cid())
|
||||
|
||||
if err := cborrpc.WriteCborRPC(s, hmsg); err != nil {
|
||||
if err := cborutil.WriteCborRPC(s, hmsg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/lotus/chain/address"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
cborrpc "github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
cborrpc "github.com/filecoin-project/lotus/lib/cborutil"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
)
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/address"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
payapi "github.com/filecoin-project/lotus/node/impl/paych"
|
||||
"github.com/filecoin-project/lotus/paych"
|
||||
"github.com/filecoin-project/lotus/retrieval/discovery"
|
||||
@ -44,7 +44,7 @@ func (c *Client) Query(ctx context.Context, p discovery.RetrievalPeer, data cid.
|
||||
}
|
||||
defer s.Close()
|
||||
|
||||
err = cborrpc.WriteCborRPC(s, &Query{
|
||||
err = cborutil.WriteCborRPC(s, &Query{
|
||||
Piece: data,
|
||||
})
|
||||
if err != nil {
|
||||
@ -172,12 +172,12 @@ func (cst *clientStream) doOneExchange(ctx context.Context, toFetch uint64, out
|
||||
},
|
||||
}
|
||||
|
||||
if err := cborrpc.WriteCborRPC(cst.stream, deal); err != nil {
|
||||
if err := cborutil.WriteCborRPC(cst.stream, deal); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var resp DealResponse
|
||||
if err := cborrpc.ReadCborRPC(cst.peeker, &resp); err != nil {
|
||||
if err := cborutil.ReadCborRPC(cst.peeker, &resp); err != nil {
|
||||
log.Error(err)
|
||||
return err
|
||||
}
|
||||
@ -209,7 +209,7 @@ func (cst *clientStream) fetchBlocks(toFetch uint64, out io.Writer) error {
|
||||
log.Infof("block %d of %d", i+1, blocksToFetch)
|
||||
|
||||
var block Block
|
||||
if err := cborrpc.ReadCborRPC(cst.peeker, &block); err != nil {
|
||||
if err := cborutil.ReadCborRPC(cst.peeker, &block); err != nil {
|
||||
return xerrors.Errorf("reading fetchBlock response: %w", err)
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/address"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
"github.com/filecoin-project/lotus/storage/sectorblocks"
|
||||
)
|
||||
|
||||
@ -42,7 +42,7 @@ func NewMiner(sblks *sectorblocks.SectorBlocks, full api.FullNode) *Miner {
|
||||
|
||||
func writeErr(stream network.Stream, err error) {
|
||||
log.Errorf("Retrieval deal error: %s", err)
|
||||
_ = cborrpc.WriteCborRPC(stream, &DealResponse{
|
||||
_ = cborutil.WriteCborRPC(stream, &DealResponse{
|
||||
Status: Error,
|
||||
Message: err.Error(),
|
||||
})
|
||||
@ -52,7 +52,7 @@ func (m *Miner) HandleQueryStream(stream network.Stream) {
|
||||
defer stream.Close()
|
||||
|
||||
var query Query
|
||||
if err := cborrpc.ReadCborRPC(stream, &query); err != nil {
|
||||
if err := cborutil.ReadCborRPC(stream, &query); err != nil {
|
||||
writeErr(stream, err)
|
||||
return
|
||||
}
|
||||
@ -74,7 +74,7 @@ func (m *Miner) HandleQueryStream(stream network.Stream) {
|
||||
answer.Size = uint64(size) // TODO: verify on intermediate
|
||||
}
|
||||
|
||||
if err := cborrpc.WriteCborRPC(stream, answer); err != nil {
|
||||
if err := cborutil.WriteCborRPC(stream, answer); err != nil {
|
||||
log.Errorf("Retrieval query: WriteCborRPC: %s", err)
|
||||
return
|
||||
}
|
||||
@ -114,7 +114,7 @@ func (m *Miner) HandleDealStream(stream network.Stream) {
|
||||
|
||||
func (hnd *handlerDeal) handleNext() (bool, error) {
|
||||
var deal DealProposal
|
||||
if err := cborrpc.ReadCborRPC(hnd.stream, &deal); err != nil {
|
||||
if err := cborutil.ReadCborRPC(hnd.stream, &deal); err != nil {
|
||||
if err == io.EOF { // client sent all deals
|
||||
err = nil
|
||||
}
|
||||
@ -203,7 +203,7 @@ func (hnd *handlerDeal) accept(deal DealProposal) error {
|
||||
resp := &DealResponse{
|
||||
Status: Accepted,
|
||||
}
|
||||
if err := cborrpc.WriteCborRPC(hnd.stream, resp); err != nil {
|
||||
if err := cborutil.WriteCborRPC(hnd.stream, resp); err != nil {
|
||||
log.Errorf("Retrieval query: Write Accepted resp: %s", err)
|
||||
return err
|
||||
}
|
||||
@ -231,7 +231,7 @@ func (hnd *handlerDeal) accept(deal DealProposal) error {
|
||||
Data: nd.RawData(),
|
||||
}
|
||||
|
||||
if err := cborrpc.WriteCborRPC(hnd.stream, block); err != nil {
|
||||
if err := cborutil.WriteCborRPC(hnd.stream, block); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
"github.com/filecoin-project/lotus/lib/sectorbuilder"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
)
|
||||
@ -71,7 +71,7 @@ func (s *Store) AddPiece(ref string, size uint64, r io.Reader, dealIDs ...uint64
|
||||
var deals DealMapping
|
||||
switch err {
|
||||
case nil:
|
||||
if err := cborrpc.ReadCborRPC(bytes.NewReader(e), &deals); err != nil {
|
||||
if err := cborutil.ReadCborRPC(bytes.NewReader(e), &deals); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if deals.Committed {
|
||||
@ -82,7 +82,7 @@ func (s *Store) AddPiece(ref string, size uint64, r io.Reader, dealIDs ...uint64
|
||||
deals.DealIDs = append(deals.DealIDs, dealIDs...)
|
||||
deals.Allocated += size
|
||||
|
||||
d, err := cborrpc.Dump(&deals)
|
||||
d, err := cborutil.Dump(&deals)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
@ -106,7 +106,7 @@ func (s *Store) PieceSizesToFill(sectorID uint64) ([]uint64, error) {
|
||||
return nil, err
|
||||
}
|
||||
var info DealMapping
|
||||
if err := cborrpc.ReadCborRPC(bytes.NewReader(e), &info); err != nil {
|
||||
if err := cborutil.ReadCborRPC(bytes.NewReader(e), &info); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if info.Allocated > s.sb.SectorSize() {
|
||||
@ -139,7 +139,7 @@ func (s *Store) DealsForCommit(sectorID uint64, commit bool) ([]uint64, error) {
|
||||
switch err {
|
||||
case nil:
|
||||
var deals DealMapping
|
||||
if err := cborrpc.ReadCborRPC(bytes.NewReader(e), &deals); err != nil {
|
||||
if err := cborutil.ReadCborRPC(bytes.NewReader(e), &deals); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !commit {
|
||||
@ -151,7 +151,7 @@ func (s *Store) DealsForCommit(sectorID uint64, commit bool) ([]uint64, error) {
|
||||
}
|
||||
|
||||
deals.Committed = true
|
||||
d, err := cborrpc.Dump(&deals)
|
||||
d, err := cborutil.Dump(&deals)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/lib/cborrpc"
|
||||
"github.com/filecoin-project/lotus/lib/cborutil"
|
||||
"github.com/filecoin-project/lotus/lib/padreader"
|
||||
"github.com/filecoin-project/lotus/lib/sectorbuilder"
|
||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||
@ -98,7 +98,7 @@ func (st *SectorBlocks) writeRef(cid cid.Cid, pieceRef string, offset uint64, si
|
||||
|
||||
var refs api.SealedRefs
|
||||
if len(v) > 0 {
|
||||
if err := cborrpc.ReadCborRPC(bytes.NewReader(v), &refs); err != nil {
|
||||
if err := cborutil.ReadCborRPC(bytes.NewReader(v), &refs); err != nil {
|
||||
return xerrors.Errorf("decoding existing refs: %w", err)
|
||||
}
|
||||
}
|
||||
@ -109,7 +109,7 @@ func (st *SectorBlocks) writeRef(cid cid.Cid, pieceRef string, offset uint64, si
|
||||
Size: size,
|
||||
})
|
||||
|
||||
newRef, err := cborrpc.Dump(&refs)
|
||||
newRef, err := cborutil.Dump(&refs)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("serializing refs: %w", err)
|
||||
}
|
||||
@ -197,7 +197,7 @@ func (st *SectorBlocks) List() (map[cid.Cid][]api.SealedRef, error) {
|
||||
}
|
||||
|
||||
var refs api.SealedRefs
|
||||
if err := cborrpc.ReadCborRPC(bytes.NewReader(ent.Value), &refs); err != nil {
|
||||
if err := cborutil.ReadCborRPC(bytes.NewReader(ent.Value), &refs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -217,7 +217,7 @@ func (st *SectorBlocks) GetRefs(k cid.Cid) ([]api.SealedRef, error) { // TODO: t
|
||||
}
|
||||
|
||||
var refs api.SealedRefs
|
||||
if err := cborrpc.ReadCborRPC(bytes.NewReader(ent), &refs); err != nil {
|
||||
if err := cborutil.ReadCborRPC(bytes.NewReader(ent), &refs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user