import { P2P } from '@shardeum-foundation/lib-types'; import { Result } from 'neverthrow'; import { JoinRequest } from '@shardeum-foundation/lib-types/build/src/p2p/JoinTypes'; export declare function setAllowBogon(value: boolean): void; export declare function getAllowBogon(): boolean; export declare let finishedSyncingCycle: number; /** FUNCTIONS */ /** CycleCreator Functions */ export declare function init(): void; export declare function reset(): void; export declare function getNodeRequestingJoin(): P2P.P2PTypes.P2PNode[]; /** calculateToAccept - calculates the number of nodes to accept into the network */ export declare function calculateToAccept(): number; export declare function getTxs(): P2P.JoinTypes.Txs; export declare function validateRecordTypes(rec: P2P.JoinTypes.Record): string; export declare function dropInvalidTxs(txs: P2P.JoinTypes.Txs): P2P.JoinTypes.Txs; export declare function updateRecord(txs: P2P.JoinTypes.Txs, record: P2P.CycleCreatorTypes.CycleRecord): void; export declare function parseRecord(record: P2P.CycleCreatorTypes.CycleRecord): P2P.CycleParserTypes.Change; /** Not used by Join */ export declare function sendRequests(): void; /** Not used by Join */ export declare function queueRequest(): void; export declare function queueStartedSyncingRequest(): Promise; export declare function queueFinishedSyncingRequest(): Promise; export declare function queueStandbyRefreshRequest(publicKey: string): void; export declare function queueJoinRequest(joinRequest: JoinRequest): void; export declare function queueUnjoinRequest(unjoinRequest: P2P.JoinTypes.SignedUnjoinRequest): void; /** Module Functions */ export declare function createJoinRequest(cycleRecord: P2P.CycleCreatorTypes.CycleRecord): Promise; export interface JoinRequestResponse { /** Whether the join request was accepted. TODO: consider renaming to `accepted`? */ success: boolean; /** A message explaining the result of the join request. */ reason: string; /** Whether the join request could not be accepted due to some error, usually in validating a join request. TODO: consider renaming to `invalid`? */ fatal: boolean; } /** * Processes a join request by validating the joining node's information, * ensuring compatibility with the network's version, checking cryptographic signatures, and responding * with either an acceptance or rejection based on the provided criteria. * * This function serves as a critical part of the network's security, allowing only valid and authenticated * nodes to participate in the network activities. * * @function * @param {P2P.JoinTypes.JoinRequest} joinRequest - The request object containing information about the joining node. * @returns {JoinRequestResponse} The result of the join request, with details about acceptance or rejection. * @throws {Error} Throws an error if the validation of the join request fails. * * */ export declare function addJoinRequest(joinRequest: P2P.JoinTypes.JoinRequest): JoinRequestResponse; export declare function firstJoin(): Promise; export declare function submitJoinV2(nodes: P2P.P2PTypes.Node[], joinRequest: P2P.JoinTypes.JoinRequest & P2P.P2PTypes.SignedObject): Promise; export declare function fetchJoined(activeNodes: P2P.P2PTypes.Node[]): Promise; export declare function fetchJoinedV2(activeNodes: P2P.P2PTypes.Node[]): Promise<{ id: string | undefined; isOnStandbyList: boolean; }>; /** * Returns a `JoinRequestResponse` object if the given `joinRequest` is invalid or rejected for any reason. */ export declare function validateJoinRequest(joinRequest: P2P.JoinTypes.JoinRequest): JoinRequestResponse | null; export declare function computeNodeId(publicKey: string, cycleMarker: string): string; /** * This function is a little weird because it was taken directly from * `addJoinRequest`, but here's how it works: * * It validates the types of the `joinRequest`. If the types are invalid, it * returns a `JoinRequestResponse` object with `success` set to `false` and * `fatal` set to `true`. The `reason` field will contain a message describing * the validation error. * * If the types are valid, it returns `null`. */ export declare function verifyJoinRequestTypes(joinRequest: P2P.JoinTypes.JoinRequest): JoinRequestResponse | null; export declare function verifyJoinRequestSignature(joinRequest: P2P.JoinTypes.JoinRequest): JoinRequestResponse | null; /** * Computes a selection number given a join request. */ export declare function computeSelectionNum(joinRequest: JoinRequest): Result; export declare function nodeListFromStates(states: P2P.P2PTypes.NodeStatus[]): P2P.NodeListTypes.Node[]; export declare function swapUnjoinRequestQueues(): void; export declare function warn(...msg: string[]): void; export declare function error(...msg: string[]): void;