Skip to content

Commit

Permalink
don't perform sync health job til we've synced for the first time
Browse files Browse the repository at this point in the history
  • Loading branch information
aditiharini committed Sep 23, 2024
1 parent 96c5788 commit 1495452
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apps/hubble/src/hubble.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const ALLOWED_CLOCK_SKEW_SECONDS = 60 * 10; // 10 minutes
export interface HubInterface {
engine: Engine;
identity: string;
performedFirstSync: boolean;
hubOperatorFid?: number;
submitMessage(message: Message, source?: HubSubmitSource): HubAsyncResult<number>;
submitMessageBundle(
Expand Down Expand Up @@ -380,7 +381,6 @@ export class Hub implements HubInterface {
private allowlistedImmunePeers: string[] | undefined;
private strictContactInfoValidation: boolean;
private strictNoSign: boolean;
private performedFirstSync = false;

private pruneMessagesJobScheduler: PruneMessagesJobScheduler;
private periodSyncJobScheduler: PeriodicSyncJobScheduler;
Expand All @@ -399,6 +399,7 @@ export class Hub implements HubInterface {
engine: Engine;
fNameRegistryEventsProvider: FNameRegistryEventsProvider;
l2RegistryProvider: L2EventsProvider;
performedFirstSync = false;

constructor(options: HubOptions) {
this.options = options;
Expand Down
5 changes: 5 additions & 0 deletions apps/hubble/src/network/sync/syncHealthJob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ export class MeasureSyncHealthJobScheduler {
}

async doJobs() {
if (!this._hub.performedFirstSync) {
log.info("Skipping SyncHealth job because we haven't performed our first sync yet");
return;

Check warning on line 181 in apps/hubble/src/network/sync/syncHealthJob.ts

View check run for this annotation

Codecov / codecov/patch

apps/hubble/src/network/sync/syncHealthJob.ts#L180-L181

Added lines #L180 - L181 were not covered by tests
}

log.info({}, "Starting compute SyncHealth job");

const startTime = Date.now() - this._startSecondsAgo * 1000;
Expand Down
1 change: 1 addition & 0 deletions apps/hubble/src/test/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class MockHub implements HubInterface {
public engine: Engine;
public gossipNode: GossipNode | undefined;
public gossipCount = 0;
public performedFirstSync = false;

constructor(db: RocksDB, engine?: Engine, gossipNode?: GossipNode) {
this.db = db;
Expand Down

0 comments on commit 1495452

Please sign in to comment.