incubed
Version:
Typescript-version of the incubed client
48 lines (47 loc) • 2.13 kB
TypeScript
/***********************************************************
* This file is part of the Slock.it IoT Layer. *
* The Slock.it IoT Layer contains: *
* - USN (Universal Sharing Network) *
* - INCUBED (Trustless INcentivized remote Node Network) *
************************************************************
* Copyright (C) 2016 - 2018 Slock.it GmbH *
* All Rights Reserved. *
************************************************************
* You may use, distribute and modify this code under the *
* terms of the license contract you have concluded with *
* Slock.it GmbH. *
* For information about liability, maintenance etc. also *
* refer to the contract concluded with Slock.it GmbH. *
************************************************************
* For more information, please refer to https://slock.it *
* For questions, please contact info@slock.it *
***********************************************************/
import Client from './Client';
import { RPCRequest, RPCResponse, ChainSpec } from '../types/types';
import { Module } from './modules';
/**
* Context for a specific chain including cache and chainSpecs.
*/
export default class ChainContext {
client: Client;
chainSpec: ChainSpec;
module: Module;
chainId: string;
lastValidatorChange: number;
genericCache: {
[key: string]: string;
};
constructor(client: Client, chainId: string, chainSpec: ChainSpec);
/**
* this function is calleds before the server is asked.
* If it returns a promise than the request is handled internally otherwise the server will handle the response.
* this function should be overriden by modules that want to handle calls internally
* @param request
*/
handleIntern(request: RPCRequest): Promise<RPCResponse>;
initCache(): void;
updateCache(): void;
getFromCache(key: string): string;
putInCache(key: string, value: string): void;
clearCache(prefix: string): void;
}