From 45b34e2bcb0d5b9193ba6d804cdc5e5f089bcd38 Mon Sep 17 00:00:00 2001 From: Daniel Mack Date: Mon, 12 Nov 2018 17:54:09 +0100 Subject: [PATCH] bootstrap: check for presence of bootstrap nodes earlier Rather than checking for the presence of bootstrap nodes on each iteration of the deferred function, do the check at initialization time and report an error immediately. License: MIT Signed-off-by: Daniel Mack --- core/bootstrap.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/core/bootstrap.go b/core/bootstrap.go index 47ed2b576..29022fe05 100644 --- a/core/bootstrap.go +++ b/core/bootstrap.go @@ -77,6 +77,12 @@ func Bootstrap(n *IpfsNode, cfg BootstrapConfig) (io.Closer, error) { // make a signal to wait for one bootstrap round to complete. doneWithRound := make(chan struct{}) + if len(cfg.BootstrapPeers()) == 0 { + // We *need* to bootstrap but we have no bootstrap peers + // configured *at all*, inform the user. + log.Error("no bootstrap nodes configured: go-ipfs may have difficulty connecting to the network") + } + // the periodic bootstrap function -- the connection supervisor periodic := func(worker goprocess.Process) { ctx := procctx.OnClosingContext(worker) @@ -138,11 +144,6 @@ func bootstrapRound(ctx context.Context, host host.Host, cfg BootstrapConfig) er // if connected to all bootstrap peer candidates, exit if len(notConnected) < 1 { log.Debugf("%s no more bootstrap peers to create %d connections", id, numToDial) - if len(peers) == 0 { - // We *need* to bootstrap but we have no bootstrap peers - // configured *at all*, inform the user. - log.Error("no bootstrap nodes configured: go-ipfs may have difficulty connecting to the network") - } return ErrNotEnoughBootstrapPeers }