/** * @typedef {import("./account/AccountId.js").default} AccountId * @typedef {import("./channel/Channel.js").default} Channel * @typedef {import("./channel/MirrorChannel.js").default} MirrorChannel * @typedef {import("./address_book/NodeAddress.js").default} NodeAddress */ /** * @template {Channel | MirrorChannel} ChannelT * @typedef {object} NewNode * @property {string | ManagedNodeAddress} address * @property {(address: string, cert?: string) => ChannelT} channelInitFunction */ /** * @template {Channel | MirrorChannel} ChannelT * @typedef {object} CloneNode * @property {ManagedNode} node * @property {ManagedNodeAddress} address */ /** * @abstract * @template {Channel | MirrorChannel} ChannelT */ export default class ManagedNode { /** * @param {object} props * @param {NewNode=} [props.newNode] * @param {CloneNode=} [props.cloneNode] */ constructor(props?: { newNode?: NewNode | undefined; cloneNode?: CloneNode | undefined; }); _address: ManagedNodeAddress; /** @type {string=} */ _cert: string | undefined; /** @type {ChannelT | null} */ _channel: ChannelT | null; /** @type {(address: string, cert?: string) => ChannelT} */ _channelInitFunction: (address: string, cert?: string) => ChannelT; _lastUsed: number; _readmitTime: number; _useCount: number; _badGrpcStatusCount: number; _minBackoff: number; _maxBackoff: number; _currentBackoff: number; /** * @abstract * @returns {string} */ getKey(): string; /** * @abstract * @returns {ManagedNode} */ toInsecure(): ManagedNode; /** * @abstract * @returns {ManagedNode} */ toSecure(): ManagedNode; /** * @param {string} ledgerId * @returns {this} */ setCert(ledgerId: string): this; /** * @returns {ManagedNodeAddress} */ get address(): ManagedNodeAddress; /** * @returns {number} */ get attempts(): number; /** * @returns {number} */ get minBackoff(): number; /** * @param {number} minBackoff * @returns {this} */ setMinBackoff(minBackoff: number): this; /** * @returns {number} */ get maxBackoff(): number; /** * @param {number} maxBackoff * @returns {this} */ setMaxBackoff(maxBackoff: number): this; getChannel(): ChannelT; __lastUsed: number | undefined; /** * Determines if this node is healthy by checking if this node hasn't been * in use for a the required `_currentBackoff` period. Since this looks at `this._lastUsed` * and that value is only set in the `wait()` method, any node that has not * returned a bad gRPC status will always be considered healthy. * * @returns {boolean} */ isHealthy(): boolean; increaseBackoff(): void; decreaseBackoff(): void; /** * @returns {number} */ getRemainingTime(): number; /** * This is only ever called if the node itself is down. * A node returning a transaction with a bad status code does not indicate * the node is down, and hence this method will not be called. * * @returns {Promise} */ backoff(): Promise; /** * @param {ManagedNode<*>} node * @returns {number} */ compare(node: ManagedNode): number; close(): void; } export type AccountId = import("./account/AccountId.js").default; export type Channel = import("./channel/Channel.js").default; export type MirrorChannel = import("./channel/MirrorChannel.js").default; export type NodeAddress = import("./address_book/NodeAddress.js").default; export type NewNode = { address: string | ManagedNodeAddress; channelInitFunction: (address: string, cert?: string) => ChannelT; }; export type CloneNode = { node: ManagedNode; address: ManagedNodeAddress; }; import ManagedNodeAddress from "./ManagedNodeAddress.js";