Skip to content

Commit 45b34e2

Browse files
committed
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 <[email protected]>
1 parent a88cd82 commit 45b34e2

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

core/bootstrap.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ func Bootstrap(n *IpfsNode, cfg BootstrapConfig) (io.Closer, error) {
7777
// make a signal to wait for one bootstrap round to complete.
7878
doneWithRound := make(chan struct{})
7979

80+
if len(cfg.BootstrapPeers()) == 0 {
81+
// We *need* to bootstrap but we have no bootstrap peers
82+
// configured *at all*, inform the user.
83+
log.Error("no bootstrap nodes configured: go-ipfs may have difficulty connecting to the network")
84+
}
85+
8086
// the periodic bootstrap function -- the connection supervisor
8187
periodic := func(worker goprocess.Process) {
8288
ctx := procctx.OnClosingContext(worker)
@@ -138,11 +144,6 @@ func bootstrapRound(ctx context.Context, host host.Host, cfg BootstrapConfig) er
138144
// if connected to all bootstrap peer candidates, exit
139145
if len(notConnected) < 1 {
140146
log.Debugf("%s no more bootstrap peers to create %d connections", id, numToDial)
141-
if len(peers) == 0 {
142-
// We *need* to bootstrap but we have no bootstrap peers
143-
// configured *at all*, inform the user.
144-
log.Error("no bootstrap nodes configured: go-ipfs may have difficulty connecting to the network")
145-
}
146147
return ErrNotEnoughBootstrapPeers
147148
}
148149

0 commit comments

Comments
 (0)