verus-zmq-client
Version:
Verus Coin Javascript/Typescript client for ZMQ messaging.
41 lines (40 loc) • 1.56 kB
TypeScript
/// <reference types="node" />
type BeforeEventCallback = (value: EventData, topic?: string) => Object;
type AfterEventCallback = (value: EventData, topic?: string, result?: Object) => void;
type ReceivedEventCallback = (value: EventData, topic?: string, result?: Object) => Object;
export type EventData = string | Buffer;
export interface EventReturn {
[key: string]: (value: EventData, topic?: string, result?: Object) => Object | void;
}
export declare enum SubscriptionTopics {
rawTx = "rawtx",
hashTx = "hashtx",
rawBlock = "rawblock",
hashBlock = "hashblock",
sequence = "sequence"
}
export interface SubscriptionEventsHandler {
before?: BeforeEventCallback;
after?: AfterEventCallback;
onRawTxReceived?: ReceivedEventCallback;
onHashTxReceived?: ReceivedEventCallback;
onRawBlockReceived?: ReceivedEventCallback;
onHashBlockReceived?: ReceivedEventCallback;
onSequenceReceived?: ReceivedEventCallback;
}
export declare class VerusZmqConnection {
private address;
private port;
private protocol;
constructor(address: string, port: number, protocol?: string);
getAddress(): string;
}
export declare class VerusZmqOptions {
readonly connection: VerusZmqConnection;
readonly topics: SubscriptionTopics[];
private readonly events;
constructor(server: VerusZmqConnection, topics: SubscriptionTopics[], events: SubscriptionEventsHandler);
readonly getTopics: (topics: SubscriptionTopics[]) => SubscriptionTopics[];
getEventHandlers(): EventReturn;
}
export {};