Commit 9055bd69 authored by Matt Joiner's avatar Matt Joiner

Include BootstrapOnce

parent c6e2fde1
......@@ -65,6 +65,15 @@ func (dht *IpfsDHT) BootstrapWithConfig(ctx context.Context, cfg BootstrapConfig
return nil
}
// This is a synchronous bootstrap. cfg.Queries queries will run each with a
// timeout of cfg.Timeout. cfg.Period is not used.
func (dht *IpfsDHT) BootstrapOnce(ctx context.Context, cfg BootstrapConfig) error {
if cfg.Queries <= 0 {
return fmt.Errorf("invalid number of queries: %d", cfg.Queries)
}
return dht.runBootstrap(ctx, cfg)
}
func newRandomPeerId() peer.ID {
id := make([]byte, 32) // SHA256 is the default. TODO: Use a more canonical way to generate random IDs.
rand.Read(id)
......
......@@ -709,10 +709,7 @@ func TestPeriodicBootstrap(t *testing.T) {
t.Logf("bootstrapping them so they find each other. %d", nDHTs)
for _, dht := range dhts {
err := dht.BootstrapWithConfig(ctx, cfg)
if err != nil {
t.Fatalf("error bootstrapping a dht: %s", err)
}
go dht.BootstrapOnce(ctx, cfg)
}
// this is async, and we dont know when it's finished with one cycle, so keep checking
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment