-
Notifications
You must be signed in to change notification settings - Fork 71
Releases: EOSIO/demux-js
v4.0.0
b93a09a 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 Effects, 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, andhandlerVersionNameproperties to be public. - Changed the signature of
handleBlockto(nextBlock: NextBlock, isReplay: boolean) handleBlockmethod now returns eithernullor a number, if it needs to request the Action Reader for a specific block by number.- New public
infoproperty, which returns information about the handler's state - New abstract protected
setupmethod, which is implemented to set up any dependent structures needed by the implemented class (such as database connections). - New public
initializemethod, which runs the abovesetupmethod as well as any other internally needed initialization. - New protected
matchActionTypemethod, 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
applyUpdatersto(state: any, block: Block, context: any, isReplay: boolean,) - Changed the signature of
runEffectsto(versionedActions: VersionedAction[], context: any, nextBlock: NextBlock) - Changed the signature of
handleActionsto(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
nextBlockhas been renamed togetNextBlockand its return type is nowPromise<NextBlock> - New public
infoproperty, which returns information about the reader's state - New abstract protected
setupmethod, which is implemented to set up any dependent structures needed by the implemented class (such as blockchain connections). - New public
initializemethod, which runs the abovesetupmethod 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
infoproperty, which returns information about the watcher's state, as well as the states of the passed in reader and handler. - New public
statusproperty, which returns the watcher's status, which is one of theIndexingStatusenum.
Interfaces
- All interfaces are now exported and available to external modules
- New
ActionReaderOptionsinterface, which describes the possible options passed to the AbstractActionReader constructor. - New
NextBlockinterface, which contains information about the next block the handler should process. - New
BlockMetainterface, which contains supplementary information about theBlockpassed to the ActionHandler. - Interface
Effectnow has optionaldeferUntilIrreversibleproperty, which, whentrue, indicates the effect should not run until irreversibility of the block that triggered it is reached. - New
VersionedActioninterface, which helps the ActionHandler correlate theActionTypewith theHandlerVersionneeded to triggerEffects. - New
CurriedEffectRuninterface, which curries therunfunction on deferredEffects with arguments, preparing it to be run once irreversibility is reached. - New
DeferredEffectsinterface, which keys block numbers to their respectiveCurriedEffectRuns. - New
ReaderInfointerface, which is used for theAbstractActionReader'sinfoproperty. - New
HandlerInfointerface, which is used for theAbstractActionHandler'sinfoproperty. - New
DemuxInfointerface, which is used for theBaseActionWatcher'sinfoproperty. - New
IndexingStatusenum, 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.
Assets 2
v3.1.0
63f6a09 Breaking changes
On the AbstractActionReader:
- Protected method
historyExhaustedwas removed. - A new public abstract method
getLastIrreversibleBlockNumberwas added.
Bug Fixes
Effects are now handled correctly when using HandlerVersions.
Assets 2
v3.0.0 Pre-release
This release enables the ability to change sets of Updater and Effects facilitated by the interface HandlerVersion. HandlerVersions have a versionName string, and also Updater and Effect arrays. When you instantiate an implementation of AbstractActionHandler, you give it an array of HandlerVersions. 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
ActionListenerthatUpdaterandEffectinterfaces inherit from Updater'srunattribute has been renamed toapply; new optionalrevertattribute- New optional
onRollbackparameter onEffect - New
HandlerVersioninterface - IndexState now requires an additional
handlerVersionNameattribute - IndexState now keeps track of
isReplaystate
- There is now a parent interface
AbstractActionHandler- Constructor now takes an array of
HandlerVersions instead ofUpdaterandEffectarrays updateIndexStatenow takes ahandlerVersionNameparameterrunUpdatershas been renamed toapplyUpdaters- When the
applymethod onUpdaters return a value, this signalsrunUpdatersto update theHandlerVersionto the returnedversionName - To accommodate changing
HandlerVersions in the middle of a block,runEffectsnow takes aversionedActionsargument to decide which effects to run
- Constructor now takes an array of
Bugfixes
- Example now successfully recovers from micro-forks
Assets 2
v2.0.0
b1679a2 Breaking changes
On the AbstractActionReader:
- Protected method
rollbackhas been renamed toresolveFork - Protected method
rollbackExhaustedhas 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.
Assets 2
v1.0.5
v1.0.3
npm package name is now demux
We have obtained the NPM package name demux and in this release we have switched to it.
Assets 2
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-eosordemux-postgresdepending 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.