Fix stopAfter
This commit is contained in:
parent
818c1d8ab6
commit
d77af12f67
|
@ -1,4 +1,5 @@
|
||||||
// TODO: Namespace packages properly (outside of `main`)
|
// TODO: Namespace packages properly (outside of `main`)
|
||||||
|
// TODO: Apply peer-age filter to results?
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
@ -30,7 +31,7 @@ type Options struct {
|
||||||
Concurrency int `short:"c" long:"concurrency" description:"Maximum number of concurrent connections to open." default:"10"`
|
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/"`
|
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"`
|
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{
|
var logLevels = []log.Level{
|
||||||
|
|
|
@ -120,6 +120,11 @@ func (c *Crawler) Run(numWorkers int, stopAfter int) *[]Result {
|
||||||
|
|
||||||
results := []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
|
// 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.
|
// manage the number of concurrent workers but I can't think of it right now.
|
||||||
for {
|
for {
|
||||||
|
|
Loading…
Reference in New Issue