Skip to content

Commit 3cd7d2e

Browse files
committed
fix: push to the right of the queue
1 parent 7618ccf commit 3cd7d2e

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

src/datastore/chainhooks-notifier.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export class ChainhooksNotifier {
2929
*/
3030
async notify(reOrg: ReOrgUpdatedEntities, indexBlockHash: string, blockHeight: number) {
3131
const message = {
32-
id: `stacks-${Date.now()}`,
32+
id: `stacks-${blockHeight}-${indexBlockHash}-${Date.now()}`,
3333
payload: {
3434
chain: 'stacks',
3535
network: this.chainId === ChainID.Mainnet ? 'mainnet' : 'testnet',
@@ -50,7 +50,7 @@ export class ChainhooksNotifier {
5050
},
5151
};
5252
logger.info(message, 'ChainhooksNotifier broadcasting index progress message');
53-
await this.redis.lpush(this.queue, JSON.stringify(message));
53+
await this.redis.rpush(this.queue, JSON.stringify(message));
5454
}
5555

5656
async close() {

src/datastore/pg-write-store.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,13 @@ export class PgWriteStore extends PgStore {
410410
// Send block updates but don't block current execution unless we're testing.
411411
if (isTestEnv) await this.sendBlockNotifications({ data, garbageCollectedMempoolTxs });
412412
else void this.sendBlockNotifications({ data, garbageCollectedMempoolTxs });
413-
await this.chainhooksNotifier?.notify(
414-
reorg,
415-
data.block.index_block_hash,
416-
data.block.block_height
417-
);
413+
if (data.block.block_height >= 1) {
414+
await this.chainhooksNotifier?.notify(
415+
reorg,
416+
data.block.index_block_hash,
417+
data.block.block_height
418+
);
419+
}
418420
}
419421

420422
/**

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ async function init(): Promise<void> {
130130
dbWriteStore = await PgWriteStore.connect({
131131
usageName: `write-datastore-${apiMode}`,
132132
skipMigrations: apiMode === StacksApiMode.readOnly,
133-
withChainhooksNotifier: parseBoolean(process.env['CHAINHOOKS_NOTIFIER_ENABLED']) || false,
133+
withChainhooksNotifier: parseBoolean(process.env['CHAINHOOKS_NOTIFIER_ENABLED']) ?? false,
134134
});
135135
registerMempoolPromStats(dbWriteStore.eventEmitter);
136136
}

0 commit comments

Comments
 (0)