Commit 98cf9149 authored by Steven Allen's avatar Steven Allen

chore(bootstrap): remove unecessary request structure

parent 632f3c5c
......@@ -70,7 +70,7 @@ type IpfsDHT struct {
bootstrapCfg opts.BootstrapConfig
triggerAutoBootstrap bool
triggerBootstrap chan *bootstrapReq
triggerBootstrap chan struct{}
latestSelfWalk time.Time // the last time we looked-up our own peerID in the network
}
......@@ -163,7 +163,7 @@ func makeDHT(ctx context.Context, h host.Host, dstore ds.Batching, protocols []p
routingTable: rt,
protocols: protocols,
bucketSize: bucketSize,
triggerBootstrap: make(chan *bootstrapReq),
triggerBootstrap: make(chan struct{}),
}
dht.ctx = dht.newContextWithLocalTags(ctx)
......
......@@ -43,15 +43,6 @@ func init() {
}
}
type bootstrapReq struct {
errChan chan error
}
func makeBootstrapReq() *bootstrapReq {
errChan := make(chan error, 1)
return &bootstrapReq{errChan}
}
// Bootstrap i
func (dht *IpfsDHT) startBootstrapping() error {
// scan the RT table periodically & do a random walk on k-buckets that haven't been queried since the given bucket period
......@@ -78,13 +69,10 @@ func (dht *IpfsDHT) startBootstrapping() error {
if err := dht.doBootstrap(ctx, walkSelf); err != nil {
logger.Warning("bootstrap error: %s", err)
}
case req := <-dht.triggerBootstrap:
case <-dht.triggerBootstrap:
logger.Infof("triggering a bootstrap: RT has %d peers", dht.routingTable.Size())
err := dht.doBootstrap(ctx, true)
select {
case req.errChan <- err:
close(req.errChan)
default:
if err := dht.doBootstrap(ctx, true); err != nil {
logger.Warning("bootstrap error: %s", err)
}
case <-ctx.Done():
return
......@@ -190,7 +178,7 @@ func (dht *IpfsDHT) selfWalk(ctx context.Context) error {
// Note: the context is ignored.
func (dht *IpfsDHT) Bootstrap(_ context.Context) error {
select {
case dht.triggerBootstrap <- makeBootstrapReq():
case dht.triggerBootstrap <- struct{}{}:
default:
}
return nil
......
......@@ -36,7 +36,7 @@ func (nn *netNotifiee) Connected(n network.Network, v network.Conn) {
dht.Update(dht.Context(), p)
if bootstrap && dht.triggerAutoBootstrap {
select {
case dht.triggerBootstrap <- makeBootstrapReq():
case dht.triggerBootstrap <- struct{}{}:
default:
}
}
......@@ -82,7 +82,7 @@ func (nn *netNotifiee) testConnection(v network.Conn) {
dht.Update(dht.Context(), p)
if bootstrap && dht.triggerAutoBootstrap {
select {
case dht.triggerBootstrap <- makeBootstrapReq():
case dht.triggerBootstrap <- struct{}{}:
default:
}
}
......
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