Skip to content

Commit

Permalink
merkledag: keep key order in dedupeKeys
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
  • Loading branch information
magik6k committed Oct 19, 2017
1 parent 3fbb771 commit 913f964
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/corehttp/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ func (i *gatewayHandler) getOrHeadHandler(ctx context.Context, w http.ResponseWr
}

type sizeReadSeeker interface {
Size() uint64
Size() uint64

io.ReadSeeker
}
Expand Down
7 changes: 5 additions & 2 deletions merkledag/merkledag.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,14 @@ func GetNodes(ctx context.Context, ds DAGService, keys []*cid.Cid) []NodeGetter

// Remove duplicates from a list of keys
func dedupeKeys(cids []*cid.Cid) []*cid.Cid {
out := make([]*cid.Cid, 0, len(cids))
set := cid.NewSet()
for _, c := range cids {
set.Add(c)
if set.Visit(c) {
out = append(out, c)
}
}
return set.Keys()
return out
}

func newNodePromise(ctx context.Context) NodeGetter {
Expand Down

0 comments on commit 913f964

Please sign in to comment.