@cryptotaxi247 / kubo / commits / b1b42a560

change BatchFetch to return indices

Jeromy committed Nov 21, 2014 at 01:20 UTC b1b42a560910e60eceb047f56676851e5693fb38
1 file changed +4 -4
merkledag/merkledag.go
+4 -4
@@ -289,8 +289,8 @@ func FetchGraph(ctx context.Context, root *Node, serv DAGService) chan struct{}
289 // Take advantage of blockservice/bitswap batched requests to fetch all
290 // child nodes of a given node
291 // TODO: finish this
292 -func (ds *dagService) BatchFetch(ctx context.Context, root *Node) chan struct{} {
293 - sig := make(chan struct{})
292 +func (ds *dagService) BatchFetch(ctx context.Context, root *Node) <-chan int {
293 + sig := make(chan int)
294 go func() {
295 var keys []u.Key
296 for _, lnk := range root.Links {
@@ -323,11 +323,11 @@ func (ds *dagService) BatchFetch(ctx context.Context, root *Node) chan struct{}
323
324 //
325 if next == i {
326 - sig <- struct{}{}
326 + sig <- next
327 next++
328 for {
329 if _, ok := seen[next]; ok {
330 - sig <- struct{}{}
330 + sig <- next
331 next++
332 } else {
333 break