Comparing version 4.0.1-ff84e5a.0 to 5.0.1-91163c0.0
import * as Logger from 'bunyan'; | ||
import { Block, HandlerInfo, HandlerVersion, IndexState, NextBlock, VersionedAction } from './interfaces'; | ||
import { HandlerInfo, HandlerVersion, IndexState, NextBlock, VersionedAction } from './interfaces'; | ||
/** | ||
@@ -39,3 +39,3 @@ * Takes `block`s output from implementations of `AbstractActionReader` and processes their actions through the | ||
*/ | ||
protected abstract updateIndexState(state: any, block: Block, isReplay: boolean, handlerVersionName: string, context?: any): Promise<void>; | ||
protected abstract updateIndexState(state: any, nextBlock: NextBlock, isReplay: boolean, handlerVersionName: string, context?: any): Promise<void>; | ||
/** | ||
@@ -75,3 +75,3 @@ * Returns a promise for the `lastProcessedBlockNumber` and `lastProcessedBlockHash` meta state, | ||
*/ | ||
protected applyUpdaters(state: any, block: Block, context: any, isReplay: boolean): Promise<VersionedAction[]>; | ||
protected applyUpdaters(state: any, nextBlock: NextBlock, context: any, isReplay: boolean): Promise<VersionedAction[]>; | ||
/** | ||
@@ -78,0 +78,0 @@ * Process versioned actions against asynchronous side effects. |
@@ -113,3 +113,7 @@ "use strict"; | ||
matchActionType(candidateType, subscribedType) { | ||
return candidateType === subscribedType; | ||
const [candidateContract, candidateAction] = candidateType.split('::'); | ||
const [subscribedContract, subscribedAction] = subscribedType.split('::'); | ||
const contractsMatch = candidateContract === subscribedContract || subscribedContract === '*'; | ||
const actionsMatch = candidateAction === subscribedAction || subscribedAction === '*'; | ||
return contractsMatch && actionsMatch; | ||
} | ||
@@ -122,6 +126,6 @@ /** | ||
*/ | ||
applyUpdaters(state, block, context, isReplay) { | ||
applyUpdaters(state, nextBlock, context, isReplay) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const versionedActions = []; | ||
const { actions, blockInfo } = block; | ||
const { block: { actions, blockInfo } } = nextBlock; | ||
for (const action of actions) { | ||
@@ -140,3 +144,3 @@ let updaterIndex = -1; | ||
this.warnSkippingUpdaters(updaterIndex, action.type); | ||
yield this.updateIndexState(state, block, isReplay, newVersion, context); | ||
yield this.updateIndexState(state, nextBlock, isReplay, newVersion, context); | ||
this.handlerVersionName = newVersion; | ||
@@ -175,7 +179,7 @@ break; | ||
const { blockInfo } = block; | ||
const versionedActions = yield this.applyUpdaters(state, block, context, isReplay); | ||
const versionedActions = yield this.applyUpdaters(state, nextBlock, context, isReplay); | ||
if (!isReplay) { | ||
this.runEffects(versionedActions, context, nextBlock); | ||
} | ||
yield this.updateIndexState(state, block, isReplay, this.handlerVersionName, context); | ||
yield this.updateIndexState(state, nextBlock, isReplay, this.handlerVersionName, context); | ||
this.lastProcessedBlockNumber = blockInfo.blockNumber; | ||
@@ -182,0 +186,0 @@ this.lastProcessedBlockHash = blockInfo.blockHash; |
@@ -27,2 +27,3 @@ export interface ActionReaderOptions { | ||
blockNumber: number; | ||
lastIrreversibleBlockNumber: number; | ||
blockHash: string; | ||
@@ -29,0 +30,0 @@ handlerVersionName: string; |
{ | ||
"name": "demux", | ||
"version": "4.0.1-ff84e5a.0", | ||
"version": "5.0.1-91163c0.0", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "Julien Heller", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
91022
1309