From 8e7e5d3085dfd63020d157c6c88d1af535336faa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 22 Oct 2019 21:41:40 +0200 Subject: [PATCH] on chain deals: Fix deal state serialization --- api/api.go | 1 - chain/deals/state_store.go | 15 ++++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/api.go b/api/api.go index 1193f1d37..e0e7c142e 100644 --- a/api/api.go +++ b/api/api.go @@ -11,7 +11,6 @@ import ( "github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/peer" - sectorbuilder "github.com/filecoin-project/go-sectorbuilder" "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/address" diff --git a/chain/deals/state_store.go b/chain/deals/state_store.go index 00c5f0424..32b73835b 100644 --- a/chain/deals/state_store.go +++ b/chain/deals/state_store.go @@ -1,10 +1,11 @@ package deals import ( + "bytes" + "github.com/filecoin-project/lotus/lib/cborrpc" "github.com/ipfs/go-cid" "github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore/query" - cbor "github.com/ipfs/go-ipld-cbor" "golang.org/x/xerrors" ) @@ -22,7 +23,7 @@ func (st *StateStore) Begin(i cid.Cid, state interface{}) error { return xerrors.Errorf("Already tracking state for %s", i) } - b, err := cbor.DumpObject(state) + b, err := cborrpc.Dump(state) if err != nil { return err } @@ -76,7 +77,7 @@ func (st *MinerStateStore) MutateMiner(i cid.Cid, mutator func(*MinerDeal) error func minerMutator(m func(*MinerDeal) error) func([]byte) ([]byte, error) { return func(in []byte) ([]byte, error) { var deal MinerDeal - err := cbor.DecodeInto(in, &deal) + err := cborrpc.ReadCborRPC(bytes.NewReader(in), &deal) if err != nil { return nil, err } @@ -85,7 +86,7 @@ func minerMutator(m func(*MinerDeal) error) func([]byte) ([]byte, error) { return nil, err } - return cbor.DumpObject(deal) + return cborrpc.Dump(deal) } } @@ -100,7 +101,7 @@ func (st *ClientStateStore) MutateClient(i cid.Cid, mutator func(*ClientDeal) er func clientMutator(m func(*ClientDeal) error) func([]byte) ([]byte, error) { return func(in []byte) ([]byte, error) { var deal ClientDeal - err := cbor.DecodeInto(in, &deal) + err := cborrpc.ReadCborRPC(bytes.NewReader(in), &deal) if err != nil { return nil, err } @@ -109,7 +110,7 @@ func clientMutator(m func(*ClientDeal) error) func([]byte) ([]byte, error) { return nil, err } - return cbor.DumpObject(deal) + return cborrpc.Dump(deal) } } @@ -129,7 +130,7 @@ func (st *ClientStateStore) ListClient() ([]ClientDeal, error) { } var deal ClientDeal - err := cbor.DecodeInto(res.Value, &deal) + err := cborrpc.ReadCborRPC(bytes.NewReader(res.Value), &deal) if err != nil { return nil, err }