@aloxide/demux
v0.6.1
Published
Implement demux pattern for sync data from blockchain to a centralized database
Downloads
11
Readme
Table of content
Package @aloxide/demux
Implement demux pattern for sync data from blockchain to a centralized database.
Usage
ExpressActionWatcher
: Exposes the API methods from the BaseActionWatcher
through an Express server.
const expressWatcher = new ExpressActionWatcher(
actionReader,
actionHandler,
pollInterval,
portNumber,
);
expressWatcher.listen();
Now you can start watching for block data by making POST /start
request, and to stop receiving block data by making POST /pause
request. Between these requests, actionReader
will read block data from the blockchain and passing it to actionHandler
.
AloxideActionWatcher
: A ready-to-use action watcher with ability to get only one block per request e.g. using in a lambda function.
Call watchOnce
to read data of only one block (specified by startAtBlock
option), for example when you want to read the blockchain once per lambda invocation.
const actionWatcher = new AloxideActionWatcher(actionReader, actionHandler, 1000);
await actionWatcher.watchOnce(); // `actionHandler` will be run once