Highlights
BaseActionWatcher
and ExpressActionWatcher
The BaseActionWatcher
has three new public methods: start
, pause
, and info
, which can be called at any time after instantiation to start or pause the polling loop, or get information about the Watcher as well as its internal Reader and Handler. The new ExpressActionWatcher
subclass exposes these methods on a REST API endpoint via Express. This now makes Demux interactive, which opens up new production and development workflows. The ExpressActionWatcher
is now recommended as the preferred ActionWatcher.
Deferred Effects
When defining your Effect
s, you may now add an optional property, deferUntilIrreversible
. When true, the effect will only run when the block that triggered it becomes irreversible.
Fixed continuation / rollback bug
There was a pesky bug that prohibited you from continuing indexing after stopping demux in certain cases, which also caused problems when rolling back from micro forks. This issue has been resolved.
Error Classes
Custom error classes have been created, which make it easier to handle specific errors that are thrown by Demux.
Complete API changes
AbstractActionHandler
- Changed
lastProcessedBlockNumber
,lastProcessedBlockHash
, andhandlerVersionName
properties to be public. - Changed the signature of
handleBlock
to(nextBlock: NextBlock, isReplay: boolean)
handleBlock
method now returns eithernull
or a number, if it needs to request the Action Reader for a specific block by number.- New public
info
property, which returns information about the handler's state - New abstract protected
setup
method, which is implemented to set up any dependent structures needed by the implemented class (such as database connections). - New public
initialize
method, which runs the abovesetup
method as well as any other internally needed initialization. - New protected
matchActionType
method, which is used when comparing action types from block data and the action types that Updaters and Effects are subscribed to, returning true of false if it should match or not. By default, this function checks for equivalency (===
), however this can be implemented to match wildcards, for example. - Changed the signature of
applyUpdaters
to(state: any, block: Block, context: any, isReplay: boolean,)
- Changed the signature of
runEffects
to(versionedActions: VersionedAction[], context: any, nextBlock: NextBlock)
- Changed the signature of
handleActions
to(state: any, context: any, nextBlock: NextBlock, isReplay: boolean)
AbstractActionReader
- Signature of constructor has changed to a single options object:
(options: ActionReaderOptions = {})
- Within the options object, there is no
maxHistoryLength
, as the history is now optimized in length vialastIrreversibleBlock
. - Public method
nextBlock
has been renamed togetNextBlock
and its return type is nowPromise<NextBlock>
- New public
info
property, which returns information about the reader's state - New abstract protected
setup
method, which is implemented to set up any dependent structures needed by the implemented class (such as blockchain connections). - New public
initialize
method, which runs the abovesetup
method as well as any other internally needed initialization.
BaseActionWatcher
- New public method
start
, which will start the watcher's polling loop if paused. - New public method
pause
, which will pause the watcher's polling loop. - New public
info
property, which returns information about the watcher's state, as well as the states of the passed in reader and handler. - New public
status
property, which returns the watcher's status, which is one of theIndexingStatus
enum.
Interfaces
- All interfaces are now exported and available to external modules
- New
ActionReaderOptions
interface, which describes the possible options passed to the AbstractActionReader constructor. - New
NextBlock
interface, which contains information about the next block the handler should process. - New
BlockMeta
interface, which contains supplementary information about theBlock
passed to the ActionHandler. - Interface
Effect
now has optionaldeferUntilIrreversible
property, which, whentrue
, indicates the effect should not run until irreversibility of the block that triggered it is reached. - New
VersionedAction
interface, which helps the ActionHandler correlate theActionType
with theHandlerVersion
needed to triggerEffect
s. - New
CurriedEffectRun
interface, which curries therun
function on deferredEffect
s with arguments, preparing it to be run once irreversibility is reached. - New
DeferredEffects
interface, which keys block numbers to their respectiveCurriedEffectRun
s. - New
ReaderInfo
interface, which is used for theAbstractActionReader
'sinfo
property. - New
HandlerInfo
interface, which is used for theAbstractActionHandler
'sinfo
property. - New
DemuxInfo
interface, which is used for theBaseActionWatcher
'sinfo
property. - New
IndexingStatus
enum, which contains all the possible statuses for theBaseActionWatcher
.
Block.one makes its contribution on a voluntary basis as a member of the EOSIO community and is not responsible for ensuring the overall performance of the software or any applications related thereto. We make no representation, warranty, guarantee or undertaking in respect of the releases described herein and the related GitHub release or the EOSIO software, whether expressed or implied, and disclaim all liability that may arise from any use of the software for any purpose.