Skip to content

Commit

Permalink
Simplify bootstrap loop
Browse files Browse the repository at this point in the history
  • Loading branch information
bigs committed Jul 23, 2018
1 parent a49b548 commit e8d32a5
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions dht_bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,10 @@ func (dht *IpfsDHT) BootstrapWithConfig(cfg BootstrapConfig) (goprocess.Process,
}

proc := dht.Process().Go(func(p goprocess.Process) {
workerch := make(chan (<-chan struct{}))
bootstrap := func() {
proc := p.Go(dht.bootstrapWorker(cfg))
workerch <- proc.Closed()
}
go bootstrap()
for {
select {
case <-time.After(cfg.Period):
ch := <-workerch
select {
case <-ch:
go bootstrap()
case <-p.Closing():
return
default:
log.Warning("Previous bootstrapping attempt not completed within bootstrapping period")
}
<-p.Go(dht.bootstrapWorker(cfg)).Closed()
case <-p.Closing():
return
}
Expand Down

0 comments on commit e8d32a5

Please sign in to comment.