Skip to content

Commit

Permalink
feat: add configurable blocknum emitter
Browse files Browse the repository at this point in the history
  • Loading branch information
mitch-lbw committed Apr 9, 2024
1 parent 3cc3721 commit 178d17d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@kryptokrauts/event-processor-node-lib",
"version": "1.0.11",
"version": "1.0.12",
"description": "Wrapper for ease listening on antelope blockchain based on @blockmatic/antelope-ship-reader",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface ShipReaderWrapperConfig {
table_rows_whitelist: () => EosioReaderTableRowFilter[];
actions_whitelist: () => EosioReaderActionFilter[];
only_irreversible_blocks: boolean;
emit_current_blocknum: boolean;
}

export interface ActionData {
Expand Down
11 changes: 10 additions & 1 deletion src/eosio/ship-reader-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,16 @@ export class ShipReaderWrapper {
// subscribe to incoming blocks event
this.subscriptions.push(
blocks$.pipe<EosioReaderBlock>(takeWhile(() => !this.forked)).subscribe(async block => {
logger.trace(`Current block ${this.current_block}`);
logger.trace(`Current block ${block.block_num}`);

if (this.config.emit_current_blocknum) {
await this.kafka_wrapper.sendEvent(
JSON.stringify({
blocknum: block.block_num,
}),
'current_block',
);
}

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

0 comments on commit 178d17d

Please sign in to comment.