Fix stopAfter

This commit is contained in:
Andrey Petrov 2014-04-25 16:31:03 -07:00
parent 818c1d8ab6
commit d77af12f67
2 changed files with 7 additions and 1 deletions

View File

@ -1,4 +1,5 @@
// TODO: Namespace packages properly (outside of `main`)
// TODO: Apply peer-age filter to results?
package main
import (
@ -30,7 +31,7 @@ type Options struct {
Concurrency int `short:"c" long:"concurrency" description:"Maximum number of concurrent connections to open." default:"10"`
UserAgent string `short:"A" long:"user-agent" description:"Client name to advertise while crawling. Should be in format of '/name:x.y.z/'." default:"/btc-crawl:0.1.1/"`
PeerAge time.Duration `long:"peer-age" description:"Ignore discovered peers older than this." default:"24h"`
StopAfter int `long:"stop-after" description:"Stop crawling after this many results."`
StopAfter int `long:"stop-after" description:"Stop crawling after this many results." default:"0"`
}
var logLevels = []log.Level{

View File

@ -120,6 +120,11 @@ func (c *Crawler) Run(numWorkers int, stopAfter int) *[]Result {
results := []Result{}
if stopAfter == 0 {
// No stopping.
stopAfter = -1
}
// This is the main "event loop". Feels like there may be a better way to
// manage the number of concurrent workers but I can't think of it right now.
for {