Skip to content

Commit

Permalink
only update sync progress every 1000 records hydrated
Browse files Browse the repository at this point in the history
  • Loading branch information
holic committed Jul 31, 2023
1 parent 509380d commit b85e56c
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/store-sync/src/recs/syncToRecs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,22 @@ export async function syncToRecs<
setComponent(component, entity, record.value as ComponentValue);

recordsProcessed++;
setComponent(components.SyncProgress, singletonEntity, {
step: SyncStep.SNAPSHOT,
message: `Hydrating from snapshot to block ${initialState.blockNumber}`,
percentage: (recordsProcessed / numRecords) * 100,
});
if (recordsProcessed % 1000 === 0) {
setComponent(components.SyncProgress, singletonEntity, {
step: SyncStep.SNAPSHOT,
message: `Hydrating from snapshot to block ${initialState.blockNumber}`,
percentage: (recordsProcessed / numRecords) * 100,
});
}
}
debug(`hydrated ${table.records.length} records for table ${table.namespace}:${table.name}`);
}

setComponent(components.SyncProgress, singletonEntity, {
step: SyncStep.SNAPSHOT,
message: `Hydrating from snapshot to block ${initialState.blockNumber}`,
percentage: (recordsProcessed / numRecords) * 100,
});
}

// TODO: if startBlock is still 0, find via deploy event
Expand Down

0 comments on commit b85e56c

Please sign in to comment.