adding some new abstract types for processor redesign
This commit is contained in:
parent
9de48b5a9e
commit
f5864d582b
|
@ -0,0 +1,18 @@
|
|||
Each blockchain has three watchers,
|
||||
|
||||
- A websocket watcher for low latency
|
||||
- A querying watcher
|
||||
- And a sequence gap watcher
|
||||
|
||||
These three watchers all invoke the same handler callback.
|
||||
|
||||
The handler callback is responsible for:
|
||||
|
||||
- Providing the watchers with the necessary query filter information
|
||||
- parsing the event into a persistence object
|
||||
- invoking the persistence manager
|
||||
|
||||
The persistence manager is responsible for:
|
||||
|
||||
- Inserting records into the database in a safe manner, which takes into account that items will be seen multiple times.
|
||||
- Last write wins should be the approach taken here.
|
|
@ -6,7 +6,7 @@ import {
|
|||
getWormholeRelayerAddressWrapped,
|
||||
} from "./environment";
|
||||
import { WormholeRelayer__factory } from "@certusone/wormhole-sdk/lib/cjs/ethers-contracts";
|
||||
import { WebSocketProvider } from "./websocket";
|
||||
import { WebSocketProvider } from "./utils/websocket";
|
||||
import deliveryEventHandler from "./handlers/deliveryEventHandler";
|
||||
import sendEventHandler from "./handlers/sendEventHandler";
|
||||
import { EventHandler, getEventListener } from "./handlers/EventHandler";
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
import { ChainId, Network } from "@certusone/wormhole-sdk";
|
||||
import { EventHandler } from "../handlers/EventHandler";
|
||||
|
||||
export default abstract class AbstractWatcher {
|
||||
//store class fields from constructor
|
||||
watcherName: string;
|
||||
environment: Network;
|
||||
events: EventHandler<any>[];
|
||||
chain: ChainId;
|
||||
rpcs: string[];
|
||||
logger: any;
|
||||
|
||||
constructor(
|
||||
watcherName: string,
|
||||
environment: Network,
|
||||
events: EventHandler<any>[],
|
||||
chain: ChainId,
|
||||
rpcs: string[],
|
||||
logger: any
|
||||
) {
|
||||
this.watcherName = watcherName;
|
||||
this.environment = environment;
|
||||
this.events = events;
|
||||
this.chain = chain;
|
||||
this.rpcs = rpcs;
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
abstract startWebsocketProcessor(): Promise<void>;
|
||||
|
||||
abstract startQueryProcessor(): Promise<void>;
|
||||
|
||||
abstract startGapProcessor(): Promise<void>;
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
import { ChainId, Network } from "@certusone/wormhole-sdk";
|
||||
import { EventHandler } from "../handlers/EventHandler";
|
||||
import AbstractWatcher from "./AbstractWatcher";
|
||||
|
||||
export default class EvmWatcher extends AbstractWatcher {
|
||||
constructor(
|
||||
watcherName: string,
|
||||
environment: Network,
|
||||
events: EventHandler<any>[],
|
||||
chain: ChainId,
|
||||
rpcs: string[],
|
||||
logger: any
|
||||
) {
|
||||
super(watcherName, environment, events, chain, rpcs, logger);
|
||||
}
|
||||
|
||||
async startWebsocketProcessor(): Promise<void> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
async startQueryProcessor(): Promise<void> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
async startGapProcessor(): Promise<void> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue