deals: fix statestore

This commit is contained in:
Łukasz Magiera 2019-08-07 01:17:41 +02:00 committed by whyrusleeping
parent 7423327b26
commit cdc535394d
3 changed files with 7 additions and 4 deletions

View File

@ -93,6 +93,7 @@ func (h *Handler) Run(ctx context.Context) {
} }
go func(id cid.Cid) { go func(id cid.Cid) {
log.Info("fetching data for a deal")
err := merkledag.FetchGraph(ctx, deal.Ref, h.dag) err := merkledag.FetchGraph(ctx, deal.Ref, h.dag)
if err != nil { if err != nil {
return return
@ -102,6 +103,7 @@ func (h *Handler) Run(ctx context.Context) {
case fetched <- id: case fetched <- id:
case <-h.stop: case <-h.stop:
} }
log.Info("Fetched!")
}(deal.ProposalCid) }(deal.ProposalCid)
case id := <-fetched: case id := <-fetched:
// TODO: send response if client still there // TODO: send response if client still there

View File

@ -18,7 +18,8 @@ func (st *StateStore) Begin(i cid.Cid, s interface{}) error {
return err return err
} }
if has { if has {
return xerrors.Errorf("Already tracking state for %s", i) // TODO: uncomment after deals work
//return xerrors.Errorf("Already tracking state for %s", i)
} }
b, err := cbor.DumpObject(s) b, err := cbor.DumpObject(s)
if err != nil { if err != nil {
@ -49,7 +50,7 @@ func (st *StateStore) MutateMiner(i cid.Cid, mutator func(MinerDeal) (MinerDeal,
func minerMutator(m func(MinerDeal) (MinerDeal, error)) func([]byte) ([]byte, error) { func minerMutator(m func(MinerDeal) (MinerDeal, error)) func([]byte) ([]byte, error) {
return func(in []byte) ([]byte, error) { return func(in []byte) ([]byte, error) {
var cur MinerDeal var cur MinerDeal
err := cbor.DecodeInto(in, cur) err := cbor.DecodeInto(in, &cur)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -70,7 +71,7 @@ func (st *StateStore) MutateClient(i cid.Cid, mutator func(ClientDeal) (ClientDe
func clientMutator(m func(ClientDeal) (ClientDeal, error)) func([]byte) ([]byte, error) { func clientMutator(m func(ClientDeal) (ClientDeal, error)) func([]byte) ([]byte, error) {
return func(in []byte) ([]byte, error) { return func(in []byte) ([]byte, error) {
var cur ClientDeal var cur ClientDeal
err := cbor.DecodeInto(in, cur) err := cbor.DecodeInto(in, &cur)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -17,7 +17,7 @@ var log = logging.Logger("main")
const FlagStorageRepo = "storagerepo" const FlagStorageRepo = "storagerepo"
func main() { func main() {
logging.SetLogLevel("*", "DEBUG") logging.SetLogLevel("*", "INFO")
local := []*cli.Command{ local := []*cli.Command{
runCmd, runCmd,
initCmd, initCmd,