import type { BinaryWriteOptions } from "@protobuf-ts/runtime"; import type { IBinaryWriter } from "@protobuf-ts/runtime"; import type { BinaryReadOptions } from "@protobuf-ts/runtime"; import type { IBinaryReader } from "@protobuf-ts/runtime"; import type { PartialMessage } from "@protobuf-ts/runtime"; import { MessageType } from "@protobuf-ts/runtime"; /** * * Full State object used for two goals * Routing optimization: * User use this object to get information about cluster state and select the prioritised node for request * Cluster state monitoring: * Node use this object to get information about cluster state and check the state of other nodes * * @generated from protobuf message pb.FullState */ export interface FullState { /** * Short current node state * * @generated from protobuf field: pb.ShortState state = 1; */ state?: ShortState; /** * Signature of the short state by current node * * @generated from protobuf field: pb.StateSignature signature = 2; */ signature?: StateSignature; /** * Node statistic * * @generated from protobuf field: pb.Statistic statistic = 3; */ statistic?: Statistic; /** * Cluster map * * @generated from protobuf field: map cluster_map = 4; */ clusterMap: { [key: number]: GossipState; }; } /** * @generated from protobuf message pb.ShortState */ export interface ShortState { /** * PubKey of the node from smart contract * * @generated from protobuf field: string nodeKey = 1; */ nodeKey: string; /** * ID of the cluster from smart contract * * @generated from protobuf field: uint32 clusterID = 2; */ clusterID: number; /** * URL of the node * * @generated from protobuf field: string url = 3; */ url: string; /** * State of the node * * @generated from protobuf field: pb.State state = 4; */ state: State; /** * Location of the node (Alpha2 country code) * * @generated from protobuf field: string location = 5; */ location: string; /** * Size of the node * * @generated from protobuf field: uint32 size = 6; */ size: number; /** * Updated_at time of the short state * * @generated from protobuf field: uint64 updated = 7; */ updated: bigint; } /** * * Each CDN node provide a full cluster state to other nodes and any client * State bring short state (last updated state) and list of checks (who checks the state and what is the result) * each check is signed by CDN node, that make them * statistic is a last statistic state of CDN node, that needed for diagnostic only * sign(CID(nodeKey+ClusterID+URL+State+Location+Size+Updated_at)) * * @generated from protobuf message pb.GossipState */ export interface GossipState { /** * @generated from protobuf field: pb.ShortState last_state = 1; */ lastState?: ShortState; /** * @generated from protobuf field: pb.StateSignature signature = 2; */ signature?: StateSignature; /** * @generated from protobuf field: pb.Statistic statistic = 3; */ statistic?: Statistic; /** * @generated from protobuf field: map checks = 4; */ checks: { [key: number]: Check; }; } /** * * Signed check, that was produced by another CDN node * and can be used to verify that the node works * * @generated from protobuf message pb.Check */ export interface Check { /** * @generated from protobuf field: pb.ShortState state = 1; */ state?: ShortState; /** * @generated from protobuf field: pb.StateSignature signature = 2; */ signature?: StateSignature; } /** * * A signature and details to help verify it. * * #### Generation * * - Take hash for the stat object * - The hash function should be blake2b-256 and `multiHashType` should be empty. * - Base encoded in Base32 with the prefix `b` * - Example: * - Store the public key of the signer in `publicKey` in binary encoding. * * - Store the current time in `timestamp` * - In JavaScript: `timestamp = +new Date()` * * - Format the current time in ISO 8601 `YYYY-MM-DDTHH:mm:ss.sssZ` * - In JavaScript: `timeText = new Date(timestamp).toISOString()` * - In Go format: `2006-01-02T15:04:05.000Z` * * - The signed message to store a state is: * - `DDC CDN ${state_hash} at ${timeText}` * - Note: the `` added for same format as piece signature is. * - Example: `DDC CDN "Hash" at 2022-06-27T07:33:44.607Z` * * - It is normal, if time of signing is bigger from state timestamp. * - The State hash is: * - Short state: `Hash = CID(nodeKey+ClusterID+URL+State+Location+Size+Updated_at)` * - The signing scheme should be sr25519, and `scheme` should be empty. * - If this not supported by a signer, then `scheme` should be "ed25519". * * - Sign and store the signature in `sig` in binary encoding. * * #### Verification * * - Recompute the signed message using the details in `signature`. * - Verify `sig` given the scheme, the message, and the public key. * * * @generated from protobuf message pb.StateSignature */ export interface StateSignature { /** * The cryptographic signature in binary encoding as per the scheme. * * @generated from protobuf field: bytes value = 1; */ value: Uint8Array; /** * The public key of the signer in binary encoding as per the scheme. * * @generated from protobuf field: bytes signer = 2; */ signer: Uint8Array; /** * The name of the signature scheme (sr25519, secp256k1, ed25519). * Default and recommended value: "" or "sr25519". * * @generated from protobuf field: string scheme = 3; */ scheme: string; /** * The ID of the hashing algorithm as per multiformats/multihash. * Default and recommended value: 0 or 0xb220, meaning blake2b-256. * * @generated from protobuf field: uint64 multiHashType = 4; */ multiHashType: bigint; /** * The timestamp in UNIX milliseconds. * * @generated from protobuf field: uint64 timestamp = 5; */ timestamp: bigint; } /** * * Short statistic about node heals status * Sessions - count of active sessions * Redirects - count of redirects in current hour * Cache_size - size of cache in bytes * Cpu - cpu load in percents * Ram - ram load in percents (regarding quotes) * Hd - hard drive load in percents (regarding quotes) * Uptime - uptime in seconds from last lunch * * @generated from protobuf message pb.Statistic */ export interface Statistic { /** * @generated from protobuf field: uint32 sessions = 1; */ sessions: number; /** * @generated from protobuf field: pb.Redirects redirects = 2; */ redirects?: Redirects; /** * @generated from protobuf field: uint32 cache_size = 3; */ cacheSize: number; /** * @generated from protobuf field: uint32 cpu = 4; */ cpu: number; /** * @generated from protobuf field: uint32 ram = 5; */ ram: number; /** * @generated from protobuf field: uint32 hd = 6; */ hd: number; /** * @generated from protobuf field: int64 uptime = 7; */ uptime: bigint; } /** * * Soft redirects it is redirects thar recommended via header * Hard redirects it is redirects that forced via http code * Counted redirects on last hour * * @generated from protobuf message pb.Redirects */ export interface Redirects { /** * @generated from protobuf field: uint32 soft = 1; */ soft: number; /** * @generated from protobuf field: uint32 hard = 2; */ hard: number; } /** * @generated from protobuf enum pb.State */ export declare enum State { /** * @generated from protobuf enum value: NA = 0; */ NA = 0, /** * @generated from protobuf enum value: GRAY = 1; */ GRAY = 1, /** * @generated from protobuf enum value: GREEN = 2; */ GREEN = 2, /** * @generated from protobuf enum value: BLUE = 3; */ BLUE = 3, /** * @generated from protobuf enum value: RED = 4; */ RED = 4 } declare class FullState$Type extends MessageType { constructor(); create(value?: PartialMessage): FullState; internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: FullState): FullState; private binaryReadMap4; internalBinaryWrite(message: FullState, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter; } /** * @generated MessageType for protobuf message pb.FullState */ export declare const FullState: FullState$Type; declare class ShortState$Type extends MessageType { constructor(); create(value?: PartialMessage): ShortState; internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ShortState): ShortState; internalBinaryWrite(message: ShortState, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter; } /** * @generated MessageType for protobuf message pb.ShortState */ export declare const ShortState: ShortState$Type; declare class GossipState$Type extends MessageType { constructor(); create(value?: PartialMessage): GossipState; internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GossipState): GossipState; private binaryReadMap4; internalBinaryWrite(message: GossipState, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter; } /** * @generated MessageType for protobuf message pb.GossipState */ export declare const GossipState: GossipState$Type; declare class Check$Type extends MessageType { constructor(); create(value?: PartialMessage): Check; internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Check): Check; internalBinaryWrite(message: Check, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter; } /** * @generated MessageType for protobuf message pb.Check */ export declare const Check: Check$Type; declare class StateSignature$Type extends MessageType { constructor(); create(value?: PartialMessage): StateSignature; internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: StateSignature): StateSignature; internalBinaryWrite(message: StateSignature, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter; } /** * @generated MessageType for protobuf message pb.StateSignature */ export declare const StateSignature: StateSignature$Type; declare class Statistic$Type extends MessageType { constructor(); create(value?: PartialMessage): Statistic; internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Statistic): Statistic; internalBinaryWrite(message: Statistic, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter; } /** * @generated MessageType for protobuf message pb.Statistic */ export declare const Statistic: Statistic$Type; declare class Redirects$Type extends MessageType { constructor(); create(value?: PartialMessage): Redirects; internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Redirects): Redirects; internalBinaryWrite(message: Redirects, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter; } /** * @generated MessageType for protobuf message pb.Redirects */ export declare const Redirects: Redirects$Type; export {}; //# sourceMappingURL=state.d.ts.map