Skip to content

Commit

Permalink
Merge pull request #29 from pinax-network/rename-finalBlocksOnly
Browse files Browse the repository at this point in the history
format
  • Loading branch information
DenisCarriere authored Feb 21, 2024
2 parents 26a4a4e + 1e75007 commit 5b55894
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 1 addition & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function action(options: WebhookRunOptions) {
const finalBlocksOnly = boolean.parse(options.finalBlocksOnly);

// Block Emitter
const { emitter, moduleHash } = await setup({...options, cursor});
const { emitter, moduleHash } = await setup({ ...options, cursor });

// Queue
const queue = new PQueue({ concurrency: 1 }); // all messages are sent in block order, no need to parallelize
Expand Down Expand Up @@ -80,5 +80,3 @@ export async function action(options: WebhookRunOptions) {
http.server.close();
});
}


7 changes: 4 additions & 3 deletions src/postWebhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,18 @@ function now() {
}

let blocks = 0;
let start = now();
const start = now();
// let lastUpdate = now();

// TO-DO replace with Prometheus metrics
function logProgress(metadata?: Metadata) {
if ( !metadata ) return;
if (!metadata) return;
const delta = now() - start;
const rate = Math.round(blocks / delta);
const minutes = Math.round(delta / 60);
const seconds = delta % 60;
if ( blocks ) logUpdate(`[app] timestamp=${metadata.clock.timestamp} block_number=${metadata.clock.number} blocks=${blocks} [${rate} b/s] (${minutes}m ${seconds}s)`);
if (blocks)
logUpdate(`[app] timestamp=${metadata.clock.timestamp} block_number=${metadata.clock.number} blocks=${blocks} [${rate} b/s] (${minutes}m ${seconds}s)`);
blocks++;
}

Expand Down

0 comments on commit 5b55894

Please sign in to comment.