Private
beforePrivate
blockPrivate
cachePrivate
configPrivate
ledgerPrivate
loggerPrivate
pendingPrivate
schedulerPrivate
stopPrivate
transactionthe internal ledger client
Private
assertPrivate
fetchPrivate
fetchListens for blocks starting at last mined block. Consider running walk before, if you need to process the history also.
The config parameter intervalSeconds
Private
listenCalled before the exiting (after the job stopped). Use this to do cleanups on your side
Sets the block handler. Block Handlers are called after Transaction handlers.
the blocks transactions are attached also.
Sets the transaction handler for pending transactions.
Pending transactions handler gives you all pending transactions on all periodical calls.
You need to track on your behalf if these transactions were processed by you or not.
This method ignores blockOffset
.
Sets the transactions handler. This handler calls once for each transaction in a block.
the block handler delivers the transactions also.
Private
processIterates over the blocks beginning with startHeight until the current block.
This method processes each block as quick as possible (depending on the handlers), without
any further delays. Usually, you want to use this before listen
Usage
This method is useful, if you want to reconstruct for example a database based on the blockchain data. Due to its immutability and integrity the blockchain is your "Single Source of Truth" and though your secure backup.
Note, that this operation can take several minutes. It can be sped up significantly, if running against a local node.
On processing errors this method tries to recover, i.e. retrying several times (p-retry) before it stops.
Optional
startHeight: numberThe block height where to start. If there's a cached height > startHeight
, the cached height is taken instead.
This way it is possible, to continue on already processed data and somehow halted process (due to processing errors), without beginning from the startHeight
.
If you really want to start from scratch you need to delete the cache file.
Generated using TypeDoc
The ChainWalker allows to either walk from a given block height until the last mined block and/or to listen to the blockchain.
Usage Listen Mode
When you just need to react on incoming blocks/transactions
Usage Walk Mode
When you want to gather data from the ledger, i.e. reading past blocks/transactions. Good for analysis, or (re)building a database.
In each mode the same callbacks are called, such that blocks and transactions can be processed according your needs.
The callbacks are called in this order:
and when stopping/interrupting onBeforeQuit