Skip to content

Commit

Permalink
Create ccq topics before connecting to peers
Browse files Browse the repository at this point in the history
  • Loading branch information
bruce-riley committed Oct 3, 2023
1 parent 057ab6d commit 6abf854
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions node/pkg/p2p/p2p.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,23 +327,6 @@ func Run(
}
defer sub.Cancel()

// Make sure we connect to at least 1 bootstrap node (this is particularly important in a local devnet and CI
// as peer discovery can take a long time).

successes := connectToPeers(ctx, logger, h, bootstrappers)

if successes == 0 && !bootstrapNode { // If we're a bootstrap node it's okay to not have any peers.
// If we fail to connect to any bootstrap peer, kill the service
// returning from this function will lead to rootCtxCancel() being called in the defer() above. The service will then be restarted by Tilt/kubernetes.
return fmt.Errorf("failed to connect to any bootstrap peer")
}
logger.Info("Connected to bootstrap peers", zap.Int("num", successes))

logger.Info("Node has been started", zap.String("peer_id", h.ID().String()),
zap.String("addrs", fmt.Sprintf("%v", h.Addrs())))

bootTime := time.Now()

if ccqEnabled {
ccqErrC := make(chan error)
ccq := newCcqRunP2p(logger, ccqAllowedPeers)
Expand All @@ -365,6 +348,23 @@ func Run(
}()
}

// Make sure we connect to at least 1 bootstrap node (this is particularly important in a local devnet and CI
// as peer discovery can take a long time).

successes := connectToPeers(ctx, logger, h, bootstrappers)

if successes == 0 && !bootstrapNode { // If we're a bootstrap node it's okay to not have any peers.
// If we fail to connect to any bootstrap peer, kill the service
// returning from this function will lead to rootCtxCancel() being called in the defer() above. The service will then be restarted by Tilt/kubernetes.
return fmt.Errorf("failed to connect to any bootstrap peer")
}
logger.Info("Connected to bootstrap peers", zap.Int("num", successes))

logger.Info("Node has been started", zap.String("peer_id", h.ID().String()),
zap.String("addrs", fmt.Sprintf("%v", h.Addrs())))

bootTime := time.Now()

// Periodically run guardian state set cleanup.
go func() {
ticker := time.NewTicker(15 * time.Second)
Expand Down

0 comments on commit 6abf854

Please sign in to comment.