adding some new abstract types for processor redesign

This commit is contained in:
chase-45 2023-10-25 10:58:09 -04:00
parent 9de48b5a9e
commit f5864d582b
5 changed files with 79 additions and 1 deletions

View File

@ -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.

View File

@ -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";

View File

@ -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>;
}

View File

@ -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.");
}
}