// @generated by protobuf-ts 2.9.0 // @generated from protobuf file "state.proto" (package "pb", syntax proto3) // tslint:disable import type { BinaryWriteOptions } from "@protobuf-ts/runtime"; import type { IBinaryWriter } from "@protobuf-ts/runtime"; import { WireType } from "@protobuf-ts/runtime"; import type { BinaryReadOptions } from "@protobuf-ts/runtime"; import type { IBinaryReader } from "@protobuf-ts/runtime"; import { UnknownFieldHandler } from "@protobuf-ts/runtime"; import type { PartialMessage } from "@protobuf-ts/runtime"; import { reflectionMergePartial } from "@protobuf-ts/runtime"; import { MESSAGE_TYPE } 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; } // // Short state it's a short version of the state of the node. // State it's a enum: // NA - Not available (the node is not answering) // Gray - Not ready (the node is not ready to work) // Green - Ready (the node is ready to work in standard mode) // Blue - Node is under load. Use alternative if it's possible // Red - Node is under heavy load. Use alternative /** * @generated from protobuf enum pb.State */ export 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 } // @generated message type with reflection information, may provide speed optimized methods class FullState$Type extends MessageType { constructor() { super("pb.FullState", [ { no: 1, name: "state", kind: "message", T: () => ShortState }, { no: 2, name: "signature", kind: "message", T: () => StateSignature }, { no: 3, name: "statistic", kind: "message", T: () => Statistic }, { no: 4, name: "cluster_map", kind: "map", K: 13 /*ScalarType.UINT32*/, V: { kind: "message", T: () => GossipState } } ]); } create(value?: PartialMessage): FullState { const message = { clusterMap: {} }; globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) reflectionMergePartial(this, message, value); return message; } internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: FullState): FullState { let message = target ?? this.create(), end = reader.pos + length; while (reader.pos < end) { let [fieldNo, wireType] = reader.tag(); switch (fieldNo) { case /* pb.ShortState state */ 1: message.state = ShortState.internalBinaryRead(reader, reader.uint32(), options, message.state); break; case /* pb.StateSignature signature */ 2: message.signature = StateSignature.internalBinaryRead(reader, reader.uint32(), options, message.signature); break; case /* pb.Statistic statistic */ 3: message.statistic = Statistic.internalBinaryRead(reader, reader.uint32(), options, message.statistic); break; case /* map cluster_map */ 4: this.binaryReadMap4(message.clusterMap, reader, options); break; default: let u = options.readUnknownField; if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); let d = reader.skip(wireType); if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); } } return message; } private binaryReadMap4(map: FullState["clusterMap"], reader: IBinaryReader, options: BinaryReadOptions): void { let len = reader.uint32(), end = reader.pos + len, key: keyof FullState["clusterMap"] | undefined, val: FullState["clusterMap"][any] | undefined; while (reader.pos < end) { let [fieldNo, wireType] = reader.tag(); switch (fieldNo) { case 1: key = reader.uint32(); break; case 2: val = GossipState.internalBinaryRead(reader, reader.uint32(), options); break; default: throw new globalThis.Error("unknown map entry field for field pb.FullState.cluster_map"); } } map[key ?? 0] = val ?? GossipState.create(); } internalBinaryWrite(message: FullState, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { /* pb.ShortState state = 1; */ if (message.state) ShortState.internalBinaryWrite(message.state, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); /* pb.StateSignature signature = 2; */ if (message.signature) StateSignature.internalBinaryWrite(message.signature, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); /* pb.Statistic statistic = 3; */ if (message.statistic) Statistic.internalBinaryWrite(message.statistic, writer.tag(3, WireType.LengthDelimited).fork(), options).join(); /* map cluster_map = 4; */ for (let k of Object.keys(message.clusterMap)) { writer.tag(4, WireType.LengthDelimited).fork().tag(1, WireType.Varint).uint32(parseInt(k)); writer.tag(2, WireType.LengthDelimited).fork(); GossipState.internalBinaryWrite(message.clusterMap[k as any], writer, options); writer.join().join(); } let u = options.writeUnknownFields; if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); return writer; } } /** * @generated MessageType for protobuf message pb.FullState */ export const FullState = new FullState$Type(); // @generated message type with reflection information, may provide speed optimized methods class ShortState$Type extends MessageType { constructor() { super("pb.ShortState", [ { no: 1, name: "nodeKey", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 2, name: "clusterID", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 3, name: "url", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 4, name: "state", kind: "enum", T: () => ["pb.State", State] }, { no: 5, name: "location", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 6, name: "size", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 7, name: "updated", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ } ]); } create(value?: PartialMessage): ShortState { const message = { nodeKey: "", clusterID: 0, url: "", state: 0, location: "", size: 0, updated: 0n }; globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) reflectionMergePartial(this, message, value); return message; } internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ShortState): ShortState { let message = target ?? this.create(), end = reader.pos + length; while (reader.pos < end) { let [fieldNo, wireType] = reader.tag(); switch (fieldNo) { case /* string nodeKey */ 1: message.nodeKey = reader.string(); break; case /* uint32 clusterID */ 2: message.clusterID = reader.uint32(); break; case /* string url */ 3: message.url = reader.string(); break; case /* pb.State state */ 4: message.state = reader.int32(); break; case /* string location */ 5: message.location = reader.string(); break; case /* uint32 size */ 6: message.size = reader.uint32(); break; case /* uint64 updated */ 7: message.updated = reader.uint64().toBigInt(); break; default: let u = options.readUnknownField; if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); let d = reader.skip(wireType); if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); } } return message; } internalBinaryWrite(message: ShortState, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { /* string nodeKey = 1; */ if (message.nodeKey !== "") writer.tag(1, WireType.LengthDelimited).string(message.nodeKey); /* uint32 clusterID = 2; */ if (message.clusterID !== 0) writer.tag(2, WireType.Varint).uint32(message.clusterID); /* string url = 3; */ if (message.url !== "") writer.tag(3, WireType.LengthDelimited).string(message.url); /* pb.State state = 4; */ if (message.state !== 0) writer.tag(4, WireType.Varint).int32(message.state); /* string location = 5; */ if (message.location !== "") writer.tag(5, WireType.LengthDelimited).string(message.location); /* uint32 size = 6; */ if (message.size !== 0) writer.tag(6, WireType.Varint).uint32(message.size); /* uint64 updated = 7; */ if (message.updated !== 0n) writer.tag(7, WireType.Varint).uint64(message.updated); let u = options.writeUnknownFields; if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); return writer; } } /** * @generated MessageType for protobuf message pb.ShortState */ export const ShortState = new ShortState$Type(); // @generated message type with reflection information, may provide speed optimized methods class GossipState$Type extends MessageType { constructor() { super("pb.GossipState", [ { no: 1, name: "last_state", kind: "message", T: () => ShortState }, { no: 2, name: "signature", kind: "message", T: () => StateSignature }, { no: 3, name: "statistic", kind: "message", T: () => Statistic }, { no: 4, name: "checks", kind: "map", K: 13 /*ScalarType.UINT32*/, V: { kind: "message", T: () => Check } } ]); } create(value?: PartialMessage): GossipState { const message = { checks: {} }; globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) reflectionMergePartial(this, message, value); return message; } internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: GossipState): GossipState { let message = target ?? this.create(), end = reader.pos + length; while (reader.pos < end) { let [fieldNo, wireType] = reader.tag(); switch (fieldNo) { case /* pb.ShortState last_state */ 1: message.lastState = ShortState.internalBinaryRead(reader, reader.uint32(), options, message.lastState); break; case /* pb.StateSignature signature */ 2: message.signature = StateSignature.internalBinaryRead(reader, reader.uint32(), options, message.signature); break; case /* pb.Statistic statistic */ 3: message.statistic = Statistic.internalBinaryRead(reader, reader.uint32(), options, message.statistic); break; case /* map checks */ 4: this.binaryReadMap4(message.checks, reader, options); break; default: let u = options.readUnknownField; if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); let d = reader.skip(wireType); if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); } } return message; } private binaryReadMap4(map: GossipState["checks"], reader: IBinaryReader, options: BinaryReadOptions): void { let len = reader.uint32(), end = reader.pos + len, key: keyof GossipState["checks"] | undefined, val: GossipState["checks"][any] | undefined; while (reader.pos < end) { let [fieldNo, wireType] = reader.tag(); switch (fieldNo) { case 1: key = reader.uint32(); break; case 2: val = Check.internalBinaryRead(reader, reader.uint32(), options); break; default: throw new globalThis.Error("unknown map entry field for field pb.GossipState.checks"); } } map[key ?? 0] = val ?? Check.create(); } internalBinaryWrite(message: GossipState, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { /* pb.ShortState last_state = 1; */ if (message.lastState) ShortState.internalBinaryWrite(message.lastState, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); /* pb.StateSignature signature = 2; */ if (message.signature) StateSignature.internalBinaryWrite(message.signature, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); /* pb.Statistic statistic = 3; */ if (message.statistic) Statistic.internalBinaryWrite(message.statistic, writer.tag(3, WireType.LengthDelimited).fork(), options).join(); /* map checks = 4; */ for (let k of Object.keys(message.checks)) { writer.tag(4, WireType.LengthDelimited).fork().tag(1, WireType.Varint).uint32(parseInt(k)); writer.tag(2, WireType.LengthDelimited).fork(); Check.internalBinaryWrite(message.checks[k as any], writer, options); writer.join().join(); } let u = options.writeUnknownFields; if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); return writer; } } /** * @generated MessageType for protobuf message pb.GossipState */ export const GossipState = new GossipState$Type(); // @generated message type with reflection information, may provide speed optimized methods class Check$Type extends MessageType { constructor() { super("pb.Check", [ { no: 1, name: "state", kind: "message", T: () => ShortState }, { no: 2, name: "signature", kind: "message", T: () => StateSignature } ]); } create(value?: PartialMessage): Check { const message = {}; globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) reflectionMergePartial(this, message, value); return message; } internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Check): Check { let message = target ?? this.create(), end = reader.pos + length; while (reader.pos < end) { let [fieldNo, wireType] = reader.tag(); switch (fieldNo) { case /* pb.ShortState state */ 1: message.state = ShortState.internalBinaryRead(reader, reader.uint32(), options, message.state); break; case /* pb.StateSignature signature */ 2: message.signature = StateSignature.internalBinaryRead(reader, reader.uint32(), options, message.signature); break; default: let u = options.readUnknownField; if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); let d = reader.skip(wireType); if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); } } return message; } internalBinaryWrite(message: Check, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { /* pb.ShortState state = 1; */ if (message.state) ShortState.internalBinaryWrite(message.state, writer.tag(1, WireType.LengthDelimited).fork(), options).join(); /* pb.StateSignature signature = 2; */ if (message.signature) StateSignature.internalBinaryWrite(message.signature, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); let u = options.writeUnknownFields; if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); return writer; } } /** * @generated MessageType for protobuf message pb.Check */ export const Check = new Check$Type(); // @generated message type with reflection information, may provide speed optimized methods class StateSignature$Type extends MessageType { constructor() { super("pb.StateSignature", [ { no: 1, name: "value", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 2, name: "signer", kind: "scalar", T: 12 /*ScalarType.BYTES*/ }, { no: 3, name: "scheme", kind: "scalar", T: 9 /*ScalarType.STRING*/ }, { no: 4, name: "multiHashType", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ }, { no: 5, name: "timestamp", kind: "scalar", T: 4 /*ScalarType.UINT64*/, L: 0 /*LongType.BIGINT*/ } ]); } create(value?: PartialMessage): StateSignature { const message = { value: new Uint8Array(0), signer: new Uint8Array(0), scheme: "", multiHashType: 0n, timestamp: 0n }; globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) reflectionMergePartial(this, message, value); return message; } internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: StateSignature): StateSignature { let message = target ?? this.create(), end = reader.pos + length; while (reader.pos < end) { let [fieldNo, wireType] = reader.tag(); switch (fieldNo) { case /* bytes value */ 1: message.value = reader.bytes(); break; case /* bytes signer */ 2: message.signer = reader.bytes(); break; case /* string scheme */ 3: message.scheme = reader.string(); break; case /* uint64 multiHashType */ 4: message.multiHashType = reader.uint64().toBigInt(); break; case /* uint64 timestamp */ 5: message.timestamp = reader.uint64().toBigInt(); break; default: let u = options.readUnknownField; if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); let d = reader.skip(wireType); if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); } } return message; } internalBinaryWrite(message: StateSignature, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { /* bytes value = 1; */ if (message.value.length) writer.tag(1, WireType.LengthDelimited).bytes(message.value); /* bytes signer = 2; */ if (message.signer.length) writer.tag(2, WireType.LengthDelimited).bytes(message.signer); /* string scheme = 3; */ if (message.scheme !== "") writer.tag(3, WireType.LengthDelimited).string(message.scheme); /* uint64 multiHashType = 4; */ if (message.multiHashType !== 0n) writer.tag(4, WireType.Varint).uint64(message.multiHashType); /* uint64 timestamp = 5; */ if (message.timestamp !== 0n) writer.tag(5, WireType.Varint).uint64(message.timestamp); let u = options.writeUnknownFields; if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); return writer; } } /** * @generated MessageType for protobuf message pb.StateSignature */ export const StateSignature = new StateSignature$Type(); // @generated message type with reflection information, may provide speed optimized methods class Statistic$Type extends MessageType { constructor() { super("pb.Statistic", [ { no: 1, name: "sessions", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 2, name: "redirects", kind: "message", T: () => Redirects }, { no: 3, name: "cache_size", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 4, name: "cpu", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 5, name: "ram", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 6, name: "hd", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 7, name: "uptime", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ } ]); } create(value?: PartialMessage): Statistic { const message = { sessions: 0, cacheSize: 0, cpu: 0, ram: 0, hd: 0, uptime: 0n }; globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) reflectionMergePartial(this, message, value); return message; } internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Statistic): Statistic { let message = target ?? this.create(), end = reader.pos + length; while (reader.pos < end) { let [fieldNo, wireType] = reader.tag(); switch (fieldNo) { case /* uint32 sessions */ 1: message.sessions = reader.uint32(); break; case /* pb.Redirects redirects */ 2: message.redirects = Redirects.internalBinaryRead(reader, reader.uint32(), options, message.redirects); break; case /* uint32 cache_size */ 3: message.cacheSize = reader.uint32(); break; case /* uint32 cpu */ 4: message.cpu = reader.uint32(); break; case /* uint32 ram */ 5: message.ram = reader.uint32(); break; case /* uint32 hd */ 6: message.hd = reader.uint32(); break; case /* int64 uptime */ 7: message.uptime = reader.int64().toBigInt(); break; default: let u = options.readUnknownField; if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); let d = reader.skip(wireType); if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); } } return message; } internalBinaryWrite(message: Statistic, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { /* uint32 sessions = 1; */ if (message.sessions !== 0) writer.tag(1, WireType.Varint).uint32(message.sessions); /* pb.Redirects redirects = 2; */ if (message.redirects) Redirects.internalBinaryWrite(message.redirects, writer.tag(2, WireType.LengthDelimited).fork(), options).join(); /* uint32 cache_size = 3; */ if (message.cacheSize !== 0) writer.tag(3, WireType.Varint).uint32(message.cacheSize); /* uint32 cpu = 4; */ if (message.cpu !== 0) writer.tag(4, WireType.Varint).uint32(message.cpu); /* uint32 ram = 5; */ if (message.ram !== 0) writer.tag(5, WireType.Varint).uint32(message.ram); /* uint32 hd = 6; */ if (message.hd !== 0) writer.tag(6, WireType.Varint).uint32(message.hd); /* int64 uptime = 7; */ if (message.uptime !== 0n) writer.tag(7, WireType.Varint).int64(message.uptime); let u = options.writeUnknownFields; if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); return writer; } } /** * @generated MessageType for protobuf message pb.Statistic */ export const Statistic = new Statistic$Type(); // @generated message type with reflection information, may provide speed optimized methods class Redirects$Type extends MessageType { constructor() { super("pb.Redirects", [ { no: 1, name: "soft", kind: "scalar", T: 13 /*ScalarType.UINT32*/ }, { no: 2, name: "hard", kind: "scalar", T: 13 /*ScalarType.UINT32*/ } ]); } create(value?: PartialMessage): Redirects { const message = { soft: 0, hard: 0 }; globalThis.Object.defineProperty(message, MESSAGE_TYPE, { enumerable: false, value: this }); if (value !== undefined) reflectionMergePartial(this, message, value); return message; } internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Redirects): Redirects { let message = target ?? this.create(), end = reader.pos + length; while (reader.pos < end) { let [fieldNo, wireType] = reader.tag(); switch (fieldNo) { case /* uint32 soft */ 1: message.soft = reader.uint32(); break; case /* uint32 hard */ 2: message.hard = reader.uint32(); break; default: let u = options.readUnknownField; if (u === "throw") throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`); let d = reader.skip(wireType); if (u !== false) (u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d); } } return message; } internalBinaryWrite(message: Redirects, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter { /* uint32 soft = 1; */ if (message.soft !== 0) writer.tag(1, WireType.Varint).uint32(message.soft); /* uint32 hard = 2; */ if (message.hard !== 0) writer.tag(2, WireType.Varint).uint32(message.hard); let u = options.writeUnknownFields; if (u !== false) (u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer); return writer; } } /** * @generated MessageType for protobuf message pb.Redirects */ export const Redirects = new Redirects$Type();