Skip to content

v4.0.0

Latest
Compare
Choose a tag to compare
@flux627 flux627 released this 22 Feb 03:43
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, and handlerVersionName properties to be public.
  • Changed the signature of handleBlock to (nextBlock: NextBlock, isReplay: boolean)
  • handleBlock method now returns either null 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 above setup 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 via lastIrreversibleBlock.
  • Public method nextBlock has been renamed to getNextBlock and its return type is now Promise<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 above setup 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 the IndexingStatus 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 the Block passed to the ActionHandler.
  • Interface Effect now has optional deferUntilIrreversible property, which, when true, indicates the effect should not run until irreversibility of the block that triggered it is reached.
  • New VersionedAction interface, which helps the ActionHandler correlate the ActionType with the HandlerVersion needed to trigger Effects.
  • New CurriedEffectRun interface, which curries the run function on deferred Effects with arguments, preparing it to be run once irreversibility is reached.
  • New DeferredEffects interface, which keys block numbers to their respective CurriedEffectRuns.
  • New ReaderInfo interface, which is used for the AbstractActionReader's info property.
  • New HandlerInfo interface, which is used for the AbstractActionHandler's info property.
  • New DemuxInfo interface, which is used for the BaseActionWatcher's info property.
  • New IndexingStatus enum, which contains all the possible statuses for the BaseActionWatcher.

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.