Skip to content

Commit

Permalink
fix: Fix peer check job not actually starting
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjayprabhu committed Nov 3, 2023
1 parent 9637457 commit c37b513
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/tricky-birds-move.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@farcaster/hubble": patch
---

fix: Fix peer check job not actually starting
1 change: 1 addition & 0 deletions apps/hubble/src/network/p2p/gossipNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export class GossipNode extends TypedEmitter<NodeEvents> {

// Also start the periodic job to make sure we have peers
this._periodicPeerCheckJob = new PeriodicPeerCheckScheduler(this, bootstrapAddrs);
this._periodicPeerCheckJob.start();

return ok(undefined);
}
Expand Down
6 changes: 5 additions & 1 deletion apps/hubble/src/network/p2p/periodicPeerCheck.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cron from "node-cron";
import { GossipNode } from "./gossipNode.js";

const log = logger.child({
component: "PeriodicSyncJob",
component: "PeriodicPeerCheckScheduler",
});

type SchedulerStatus = "started" | "stopped";
Expand Down Expand Up @@ -41,6 +41,10 @@ export class PeriodicPeerCheckScheduler {

async doJobs() {
// If there are no peers, try to connect to the bootstrap peers
const allPeerIds = await this._gossipNode.allPeerIds();

Check warning on line 44 in apps/hubble/src/network/p2p/periodicPeerCheck.ts

View check run for this annotation

Codecov / codecov/patch

apps/hubble/src/network/p2p/periodicPeerCheck.ts#L44

Added line #L44 was not covered by tests
if (allPeerIds.length > 0) {
return;

Check warning on line 46 in apps/hubble/src/network/p2p/periodicPeerCheck.ts

View check run for this annotation

Codecov / codecov/patch

apps/hubble/src/network/p2p/periodicPeerCheck.ts#L46

Added line #L46 was not covered by tests
}
const result = await this._gossipNode.bootstrap(this._bootstrapPeers);
if (result.isErr()) {
log.warn({ err: result.error }, "No Connected Peers");
Expand Down

0 comments on commit c37b513

Please sign in to comment.