on chain deals: Fix deal state serialization

This commit is contained in:
Łukasz Magiera 2019-10-22 21:41:40 +02:00
parent 213ac77d08
commit 8e7e5d3085
2 changed files with 8 additions and 8 deletions

View File

@ -11,7 +11,6 @@ import (
"github.com/libp2p/go-libp2p-core/network" "github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer" "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/build"
"github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors"
"github.com/filecoin-project/lotus/chain/address" "github.com/filecoin-project/lotus/chain/address"

View File

@ -1,10 +1,11 @@
package deals package deals
import ( import (
"bytes"
"github.com/filecoin-project/lotus/lib/cborrpc"
"github.com/ipfs/go-cid" "github.com/ipfs/go-cid"
"github.com/ipfs/go-datastore" "github.com/ipfs/go-datastore"
"github.com/ipfs/go-datastore/query" "github.com/ipfs/go-datastore/query"
cbor "github.com/ipfs/go-ipld-cbor"
"golang.org/x/xerrors" "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) return xerrors.Errorf("Already tracking state for %s", i)
} }
b, err := cbor.DumpObject(state) b, err := cborrpc.Dump(state)
if err != nil { if err != nil {
return err 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) { func minerMutator(m func(*MinerDeal) error) func([]byte) ([]byte, error) {
return func(in []byte) ([]byte, error) { return func(in []byte) ([]byte, error) {
var deal MinerDeal var deal MinerDeal
err := cbor.DecodeInto(in, &deal) err := cborrpc.ReadCborRPC(bytes.NewReader(in), &deal)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -85,7 +86,7 @@ func minerMutator(m func(*MinerDeal) error) func([]byte) ([]byte, error) {
return nil, err 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) { func clientMutator(m func(*ClientDeal) error) func([]byte) ([]byte, error) {
return func(in []byte) ([]byte, error) { return func(in []byte) ([]byte, error) {
var deal ClientDeal var deal ClientDeal
err := cbor.DecodeInto(in, &deal) err := cborrpc.ReadCborRPC(bytes.NewReader(in), &deal)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -109,7 +110,7 @@ func clientMutator(m func(*ClientDeal) error) func([]byte) ([]byte, error) {
return nil, err return nil, err
} }
return cbor.DumpObject(deal) return cborrpc.Dump(deal)
} }
} }
@ -129,7 +130,7 @@ func (st *ClientStateStore) ListClient() ([]ClientDeal, error) {
} }
var deal ClientDeal var deal ClientDeal
err := cbor.DecodeInto(res.Value, &deal) err := cborrpc.ReadCborRPC(bytes.NewReader(res.Value), &deal)
if err != nil { if err != nil {
return nil, err return nil, err
} }