Skip to content

Commit

Permalink
fix(p2p.handleDatasetsList): peer's datasets now return fully hydrated
Browse files Browse the repository at this point in the history
Merge pull request #391 from qri-io/datasetsp2p
  • Loading branch information
ramfox authored May 10, 2018
2 parents e9b05df + b755554 commit 52285c1
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions p2p/datasets.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"encoding/json"
"fmt"

"github.com/ipfs/go-datastore"
"github.com/qri-io/dataset/dsfs"
"github.com/qri-io/qri/repo"

peer "gx/ipfs/QmZoWKhxUmZ2seW4BzX6fJkNR8hh9PsGModr7q171yq2SS/go-libp2p-peer"
Expand Down Expand Up @@ -75,20 +77,17 @@ func (n *QriNode) handleDatasetsList(ws *WrappedStream, msg Message) (hangup boo
return
}

// replies := make([]*repo.DatasetRef, p.Limit)
// i := 0
// for i, ref := range refs {
// if i >= p.Limit {
// break
// }
// ds, err := dsfs.LoadDataset(n.Repo.Store(), datastore.NewKey(ref.Path))
// if err != nil {
// log.Info("error loading dataset at path:", ref.Path)
// return nil
// }
// refs[i].Dataset = ds
// // i++
// }
for i, ref := range refs {
if i >= dlp.Limit {
break
}
ds, err := dsfs.LoadDataset(n.Repo.Store(), datastore.NewKey(ref.Path))
if err != nil {
log.Info("error loading dataset at path:", ref.Path)
return
}
refs[i].Dataset = ds.Encode()
}

reply, err := msg.UpdateJSON(refs)
reply = reply.WithHeaders("phase", "response")
Expand Down

0 comments on commit 52285c1

Please sign in to comment.