Skip to content

Commit 178d17d

Browse files
committed
feat: add configurable blocknum emitter
1 parent 3cc3721 commit 178d17d

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kryptokrauts/event-processor-node-lib",
3-
"version": "1.0.11",
3+
"version": "1.0.12",
44
"description": "Wrapper for ease listening on antelope blockchain based on @blockmatic/antelope-ship-reader",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/common/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface ShipReaderWrapperConfig {
4444
table_rows_whitelist: () => EosioReaderTableRowFilter[];
4545
actions_whitelist: () => EosioReaderActionFilter[];
4646
only_irreversible_blocks: boolean;
47+
emit_current_blocknum: boolean;
4748
}
4849

4950
export interface ActionData {

src/eosio/ship-reader-wrapper.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,16 @@ export class ShipReaderWrapper {
155155
// subscribe to incoming blocks event
156156
this.subscriptions.push(
157157
blocks$.pipe<EosioReaderBlock>(takeWhile(() => !this.forked)).subscribe(async block => {
158-
logger.trace(`Current block ${this.current_block}`);
158+
logger.trace(`Current block ${block.block_num}`);
159+
160+
if (this.config.emit_current_blocknum) {
161+
await this.kafka_wrapper.sendEvent(
162+
JSON.stringify({
163+
blocknum: block.block_num,
164+
}),
165+
'current_block',
166+
);
167+
}
159168

160169
// since replaying blocks is much faster, check within greater block-span
161170
let syncStateCheckInterval: number = 10 * sync_message_block_interval;

0 commit comments

Comments
 (0)