udp: fix ordering of scrapes

This commit is contained in:
Leo Balduf
2017-01-29 18:47:07 +01:00
parent 8cf49aad2e
commit 102b032c43
5 changed files with 10 additions and 5 deletions
+1 -1
View File
@@ -183,7 +183,7 @@ func (h *responseHook) HandleScrape(ctx context.Context, req *bittorrent.ScrapeR
}
for _, infoHash := range req.InfoHashes {
resp.Files[infoHash] = h.store.ScrapeSwarm(infoHash, req.AddressFamily)
resp.Files = append(resp.Files, h.store.ScrapeSwarm(infoHash, req.AddressFamily))
}
return ctx, nil
+1 -1
View File
@@ -78,7 +78,7 @@ func (l *Logic) AfterAnnounce(ctx context.Context, req *bittorrent.AnnounceReque
// HandleScrape generates a response for a Scrape.
func (l *Logic) HandleScrape(ctx context.Context, req *bittorrent.ScrapeRequest) (resp *bittorrent.ScrapeResponse, err error) {
resp = &bittorrent.ScrapeResponse{
Files: make(map[bittorrent.InfoHash]bittorrent.Scrape),
Files: make([]bittorrent.Scrape, 0, len(req.InfoHashes)),
}
for _, h := range l.preHooks {
if ctx, err = h.HandleScrape(ctx, req, resp); err != nil {