Comparing version 5.0.2-543 to 5.0.2-552
/// <reference types="bunyan" /> | ||
import { Logger } from './BunyanProvider'; | ||
import { Action, ActionHandlerOptions, Effect, EffectRunMode, HandlerInfo, HandlerVersion, IndexState, NextBlock, VersionedAction } from './interfaces'; | ||
import { Action, ActionHandler, ActionHandlerOptions, Effect, EffectRunMode, HandlerInfo, HandlerVersion, IndexState, NextBlock, VersionedAction } from './interfaces'; | ||
/** | ||
@@ -11,8 +11,8 @@ * Takes `block`s output from implementations of `AbstractActionReader` and processes their actions through the | ||
*/ | ||
export declare abstract class AbstractActionHandler { | ||
lastProcessedBlockNumber: number; | ||
lastProcessedBlockHash: string; | ||
lastIrreversibleBlockNumber: number; | ||
handlerVersionName: string; | ||
isReplay: boolean; | ||
export declare abstract class AbstractActionHandler implements ActionHandler { | ||
protected lastProcessedBlockNumber: number; | ||
protected lastProcessedBlockHash: string; | ||
protected lastIrreversibleBlockNumber: number; | ||
protected handlerVersionName: string; | ||
protected isReplay: boolean; | ||
protected log: Logger; | ||
@@ -19,0 +19,0 @@ protected effectRunMode: EffectRunMode; |
@@ -98,3 +98,5 @@ "use strict"; | ||
lastProcessedBlockHash: this.lastProcessedBlockHash, | ||
lastIrreversibleBlockNumber: this.lastIrreversibleBlockNumber, | ||
handlerVersionName: this.handlerVersionName, | ||
isReplay: this.isReplay, | ||
effectRunMode: this.effectRunMode, | ||
@@ -101,0 +103,0 @@ numberOfRunningEffects: effectInfo.numberOfRunningEffects, |
/// <reference types="bunyan" /> | ||
import { Logger } from './BunyanProvider'; | ||
import { ActionReaderOptions, Block, NextBlock, ReaderInfo } from './interfaces'; | ||
import { ActionReader, ActionReaderOptions, Block, NextBlock, ReaderInfo } from './interfaces'; | ||
/** | ||
* Reads blocks from a blockchain, outputting normalized `Block` objects. | ||
*/ | ||
export declare abstract class AbstractActionReader { | ||
startAtBlock: number; | ||
headBlockNumber: number; | ||
currentBlockNumber: number; | ||
export declare abstract class AbstractActionReader implements ActionReader { | ||
protected startAtBlock: number; | ||
protected headBlockNumber: number; | ||
protected currentBlockNumber: number; | ||
protected onlyIrreversible: boolean; | ||
@@ -19,16 +19,2 @@ protected currentBlockData: Block; | ||
/** | ||
* Loads the number of the latest block. | ||
*/ | ||
abstract getHeadBlockNumber(): Promise<number>; | ||
/** | ||
* Loads the number of the most recent irreversible block. | ||
*/ | ||
abstract getLastIrreversibleBlockNumber(): Promise<number>; | ||
/** | ||
* Loads a block with the given block number, returning a promise for a `Block`. | ||
* | ||
* @param blockNumber The number of the block to load | ||
*/ | ||
abstract getBlock(blockNumber: number): Promise<Block>; | ||
/** | ||
* Loads, processes, and returns the next block, updating all relevant state. Return value at index 0 is the `Block` | ||
@@ -58,2 +44,16 @@ * instance; return value at index 1 boolean `isRollback` determines if the implemented `AbstractActionHandler` needs | ||
/** | ||
* Loads the number of the latest block. | ||
*/ | ||
protected abstract getHeadBlockNumber(): Promise<number>; | ||
/** | ||
* Loads the number of the most recent irreversible block. | ||
*/ | ||
protected abstract getLastIrreversibleBlockNumber(): Promise<number>; | ||
/** | ||
* Loads a block with the given block number, returning a promise for a `Block`. | ||
* | ||
* @param blockNumber The number of the block to load | ||
*/ | ||
protected abstract getBlock(blockNumber: number): Promise<Block>; | ||
/** | ||
* Idempotently performs any required setup. | ||
@@ -60,0 +60,0 @@ */ |
/// <reference types="bunyan" /> | ||
import { AbstractActionHandler } from './AbstractActionHandler'; | ||
import { AbstractActionReader } from './AbstractActionReader'; | ||
import { Logger } from './BunyanProvider'; | ||
import { ActionWatcherOptions, DemuxInfo } from './interfaces'; | ||
import { ActionHandler, ActionReader, ActionWatcherOptions, DemuxInfo } from './interfaces'; | ||
/** | ||
* Coordinates implementations of `AbstractActionReader`s and `AbstractActionHandler`s in | ||
* Coordinates implementations of `ActionReader`s and `ActionHandler`s in | ||
* a polling loop. | ||
*/ | ||
export declare class BaseActionWatcher { | ||
protected actionReader: AbstractActionReader; | ||
protected actionHandler: AbstractActionHandler; | ||
protected actionReader: ActionReader; | ||
protected actionHandler: ActionHandler; | ||
/** | ||
* @param actionReader An instance of an implemented `AbstractActionReader` | ||
* @param actionHandler An instance of an implemented `AbstractActionHandler` | ||
* @param actionReader An instance of an implemented `ActionReader` | ||
* @param actionHandler An instance of an implemented `ActionHandler` | ||
* @param options | ||
@@ -26,3 +24,3 @@ */ | ||
private clean; | ||
constructor(actionReader: AbstractActionReader, actionHandler: AbstractActionHandler, options: ActionWatcherOptions); | ||
constructor(actionReader: ActionReader, actionHandler: ActionHandler, options: ActionWatcherOptions); | ||
/** | ||
@@ -29,0 +27,0 @@ * Starts a polling loop running in replay mode. |
@@ -14,3 +14,3 @@ "use strict"; | ||
/** | ||
* Coordinates implementations of `AbstractActionReader`s and `AbstractActionHandler`s in | ||
* Coordinates implementations of `ActionReader`s and `ActionHandler`s in | ||
* a polling loop. | ||
@@ -133,3 +133,3 @@ */ | ||
let headBlockNumber = 0; | ||
while (!headBlockNumber || this.actionReader.currentBlockNumber < headBlockNumber) { | ||
while (!headBlockNumber || this.actionReader.info.currentBlockNumber < headBlockNumber) { | ||
if (this.shouldPause) { | ||
@@ -140,3 +140,3 @@ this.processIntervals = []; | ||
const readStartTime = Date.now(); | ||
this.log.debug(`Processing block ${this.actionReader.currentBlockNumber + 1}...`); | ||
this.log.debug(`Processing block ${this.actionReader.info.currentBlockNumber + 1}...`); | ||
const nextBlock = yield this.actionReader.getNextBlock(); | ||
@@ -159,3 +159,3 @@ const readDuration = Date.now() - readStartTime; | ||
} | ||
headBlockNumber = this.actionReader.headBlockNumber; | ||
headBlockNumber = this.actionReader.info.headBlockNumber; | ||
} | ||
@@ -162,0 +162,0 @@ }); |
import express from 'express'; | ||
import { AbstractActionHandler } from './AbstractActionHandler'; | ||
import { AbstractActionReader } from './AbstractActionReader'; | ||
import { BaseActionWatcher } from './BaseActionWatcher'; | ||
import { ExpressActionWatcherOptions } from './interfaces'; | ||
import { ActionHandler, ActionReader, ExpressActionWatcherOptions } from './interfaces'; | ||
/** | ||
@@ -10,7 +8,9 @@ * Exposes the BaseActionWatcher's API methods through a simple REST interface using Express | ||
export declare class ExpressActionWatcher extends BaseActionWatcher { | ||
protected actionReader: AbstractActionReader; | ||
protected actionHandler: AbstractActionHandler; | ||
protected actionReader: ActionReader; | ||
protected actionHandler: ActionHandler; | ||
protected options: ExpressActionWatcherOptions; | ||
/** | ||
* @param port The port to use for the Express server | ||
* @param actionReader An instance of an implemented `ActionReader` | ||
* @param actionHandler An instance of an implemented `ActionHandler` | ||
* @param options | ||
*/ | ||
@@ -20,3 +20,3 @@ express: express.Express; | ||
private server; | ||
constructor(actionReader: AbstractActionReader, actionHandler: AbstractActionHandler, options: ExpressActionWatcherOptions); | ||
constructor(actionReader: ActionReader, actionHandler: ActionHandler, options: ExpressActionWatcherOptions); | ||
/** | ||
@@ -23,0 +23,0 @@ * Start the Express server |
@@ -26,3 +26,5 @@ "use strict"; | ||
/** | ||
* @param port The port to use for the Express server | ||
* @param actionReader An instance of an implemented `ActionReader` | ||
* @param actionHandler An instance of an implemented `ActionHandler` | ||
* @param options | ||
*/ | ||
@@ -29,0 +31,0 @@ this.express = express_1.default(); // How expressive |
/// <reference types="bunyan" /> | ||
import { LogLevel } from './BunyanProvider'; | ||
export interface ActionReader { | ||
getNextBlock(): Promise<NextBlock>; | ||
initialize(): Promise<void>; | ||
seekToBlock(blockNumber: number): Promise<void>; | ||
readonly info: ReaderInfo; | ||
} | ||
export interface LogOptions { | ||
@@ -32,2 +38,7 @@ logSource?: string; | ||
} | ||
export interface ActionHandler { | ||
handleBlock(nextBlock: NextBlock, isReplay: boolean): Promise<number | null>; | ||
initialize(): Promise<void>; | ||
readonly info: HandlerInfo; | ||
} | ||
export interface ActionHandlerOptions extends LogOptions { | ||
@@ -102,6 +113,8 @@ effectRunMode?: EffectRunMode; | ||
lastProcessedBlockHash: string; | ||
lastIrreversibleBlockNumber: number; | ||
handlerVersionName: string; | ||
effectRunMode: EffectRunMode; | ||
numberOfRunningEffects: number; | ||
effectErrors: string[]; | ||
isReplay?: boolean; | ||
effectRunMode?: EffectRunMode; | ||
numberOfRunningEffects?: number; | ||
effectErrors?: string[]; | ||
} | ||
@@ -112,4 +125,4 @@ export interface ReaderInfo { | ||
headBlockNumber: number; | ||
onlyIrreversible: boolean; | ||
lastIrreversibleBlockNumber: number; | ||
onlyIrreversible?: boolean; | ||
lastIrreversibleBlockNumber?: number; | ||
} | ||
@@ -116,0 +129,0 @@ export declare enum EffectRunMode { |
{ | ||
"name": "demux", | ||
"version": "5.0.2-543", | ||
"version": "5.0.2-552", | ||
"author": { | ||
@@ -5,0 +5,0 @@ "name": "block.one", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
130050
1771