@pokt-network/pocket-js
Version:
Pocket-js core package with the main functionalities to interact with the Pocket Network.
85 lines (84 loc) • 4.06 kB
TypeScript
import { Session } from "../rpc/models/output/session";
import { IKVStore } from "../storage/kv-store";
import { Configuration } from "../config";
import { RpcError } from "../rpc/errors/rpc-error";
import { Node } from "../rpc/models";
import { PocketAAT } from "@pokt-network/aat-js";
/**
* @class SessionManager
*/
export declare class SessionManager {
private readonly sessionMap;
private readonly routingTable;
private readonly sessionMapKey;
/**
* Creates an instance of SessionManager.
* @param {URL[]} dispatchers - Dispatcher's list.
* @param {Configuration} configuration - Pocket Configuration.
* @param {IKVStore} store - KVStore implementation.
* @memberof SessionManager
*/
constructor(dispatchers: URL[], configuration: Configuration, store: IKVStore);
/**
* Adds a new node to the routing table dispatcher's list
* @param {Node} dispatcher - New dispatcher.
* @memberof SessionManager
*/
addNewDispatcher(dispatcher: Node): void;
/**
* Returns the routing table dispatcher's count
* @returns {Number} - Dispatcher's count.
* @memberof SessionManager
*/
getDispatchersCount(): number;
/**
* Update the current session using an already requested dispatch response. Returns a Promise with the Session object or an Error when something goes wrong.
* @param {PocketAAT} pocketAAT - Pocket Authentication Token.
* @param {string} chain - Name of the Blockchain.
* @param {Configuration} configuration - Configuration object.
* @returns {Promise}
* @memberof SessionManager
*/
updateCurrentSession(session: Session, pocketAAT: PocketAAT, chain: string, configuration: Configuration): Promise<Session | Error>;
/**
* Request a new session object. Returns a Promise with the Session object or an Error when something goes wrong.
* @param {PocketAAT} pocketAAT - Pocket Authentication Token.
* @param {string} chain - Name of the Blockchain.
* @param {Configuration} configuration - Configuration object.
* @param {Configuration} configuration - Configuration object.
* @param {Configuration} retryCount - Amount of retries performed
* @returns {Promise}
* @memberof SessionManager
*/
requestNewSession(pocketAAT: PocketAAT, chain: string, configuration: Configuration, attemptCount?: number, maxAttempts?: number): Promise<Session | Error>;
/**
* Returns the current session for an specific Blockchain. Request a new session object if there's no an active Session for the specified blockchain. Returns a Promise with the Session object or a RpcErrorResponse when something goes wrong.
* @param {PocketAAT} pocketAAT - Pocket Authentication Token.
* @param {string} chain - Name of the Blockchain.
* @param {Configuration} configuration - Configuration object.
* @returns {Promise}
* @memberof SessionManager
*/
getCurrentSession(pocketAAT: PocketAAT, chain: string, configuration: Configuration, maxAttempts?: number): Promise<Session | Error>;
/**
* Creates an unique key using the PocketAAT object and the chain.
* @param {PocketAAT} pocketAAT - Pocket Authentication Token.
* @param {string} chain - Blockchain hash.
* @memberof SessionManager
*/
getSessionKey(pocketAAT: PocketAAT, chain: string): string;
/**
* Removes the first Session in the queue for the specified blockchain.
* @param {PocketAAT} pocketAAT - Pocket Authentication Token.
* @param {string} chain - Blockchain hash.
* @memberof SessionManager
*/
destroySession(pocketAAT: PocketAAT, chain: string): void;
/**
* Saves the given session to the session queue
* @param {string} key - The key under which to save the session
* @param {Session} session - The session to save
* @param {Configuration} configuration - The configuration to use
*/
saveSession(key: string, session: Session, configuration: Configuration): Session | RpcError;
}