UNPKG

@pokt-network/pocket-js

Version:

Pocket-js core package with the main functionalities to interact with the Pocket Network.

55 lines (54 loc) 1.82 kB
import { Node } from "../rpc/models/node"; import { Configuration } from "../config"; import { IKVStore } from "../storage/kv-store"; /** * * * @class Routing */ export declare class RoutingTable { readonly configuration: Configuration; readonly localNodesFileName = ""; private readonly dispatchersKey; readonly store: IKVStore; /** * Creates an instance of routing. * @param {URL[]} dispatchers - Array holding the initial dispatcher url(s). * @param {Configuration} configuration - Configuration object. * @param {IKVStore} store - KeyBase store object. * @memberof Routing */ constructor(dispatchers: URL[] | undefined, configuration: Configuration, store: IKVStore); /** * Returns the stored dispatchers urls count * @returns {number} Dispatcher nodes count. * @memberof Routing */ get dispatchersCount(): number; /** * Returns an array of random dispatchers urls from the routing table * @param {number} count - Desired number of dispatchers urls returned * @returns {URL[]} Random dispatcher urls. * @memberof Routing */ getRandomDispatchers(count: number): URL[] | Error; /** * Returns a random dispatcher node from the routing table * @returns {URL} Random dispatcher URL. * @memberof Routing */ getRandomDispatcher(): URL | Error; /** * Returns an specific node from the routing table based on public key * @param {URL} url - Node's service url. * @returns {Node} Node object. * @memberof Routing */ getDispatcher(url: URL): Node | Error; /** * Add a dispatcher url to the routing table * @param {URL} url - URL of the dispatcher node to be added. * @memberof Routing */ addDispatcher(url: URL): boolean; }