Releases: EOSIO/demux-js
v4.0.0
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.
v3.1.0
Breaking changes
On the AbstractActionReader
:
- Protected method
historyExhausted
was removed. - A new public abstract method
getLastIrreversibleBlockNumber
was added.
Bug Fixes
Effects are now handled correctly when using HandlerVersions
.
v3.0.0 Pre-release
This release enables the ability to change sets of Updater
and Effects
facilitated by the interface HandlerVersion
. HandlerVersion
s have a versionName
string, and also Updater
and Effect
arrays. When you instantiate an implementation of AbstractActionHandler
, you give it an array of HandlerVersion
s. By default, it will load either the one named v1
or the first one, if one by that name does not exist. To change versions, simply return a string from your Updater
's apply function. If a HandlerVersion
exists with a versionName
as the returned string, it will switch to that HandlerVersion
.
Breaking changes
- Interfaces have been updated/restructured
- There is now a parent interface
ActionListener
thatUpdater
andEffect
interfaces inherit from Updater
'srun
attribute has been renamed toapply
; new optionalrevert
attribute- New optional
onRollback
parameter onEffect
- New
HandlerVersion
interface - IndexState now requires an additional
handlerVersionName
attribute - IndexState now keeps track of
isReplay
state
- There is now a parent interface
AbstractActionHandler
- Constructor now takes an array of
HandlerVersion
s instead ofUpdater
andEffect
arrays updateIndexState
now takes ahandlerVersionName
parameterrunUpdaters
has been renamed toapplyUpdaters
- When the
apply
method onUpdater
s return a value, this signalsrunUpdaters
to update theHandlerVersion
to the returnedversionName
- To accommodate changing
HandlerVersion
s in the middle of a block,runEffects
now takes aversionedActions
argument to decide which effects to run
- Constructor now takes an array of
Bugfixes
- Example now successfully recovers from micro-forks
v2.0.0
Breaking changes
On the AbstractActionReader
:
- Protected method
rollback
has been renamed toresolveFork
- Protected method
rollbackExhausted
has been renamed tohistoryExhausted
This is to differentiate the methods from the AbstractActionHandler
's rollbackTo
method. If you were overriding these methods, you will need to update their names.
Bug Fixes
Fork resolution now rolls back the correct number of blocks.
v1.0.5
v1.0.3
v1.0.2
This is a project restructure that removes abstract class implementations. Class implementations will now reside in separate repositories.
Breaking changes
- Project now has simpler, flatter directory structure, and flatter import tree. Classes are now available at the root level, e.g.:
// ES6
import { AbstractActionHandler } from "demux-js"
// Using require
const { AbstractActionHandler } = require("demux-js")
-
Since class implementations are removed, you'll now have to require either
demux-eos
ordemux-postgres
depending on which one you need. -
Block info has now been factored into its own interface
BlockInfo
, and is thus nested as its own attribute insideBlock
. This is useful if you ever need to extend block info within your own implementations.
Initial release
Initial release of demux-js.