Class NodeManager

Hierarchy

  • StartStop
    • NodeManager

Constructors

  • Parameters

    • __namedParameters: {
          connectionConnectTimeoutTime?: number;
          db: DB;
          gestaltGraph: GestaltGraph;
          keyRing: KeyRing;
          logger?: Logger;
          nodeConnectionManager: NodeConnectionManager;
          nodeGraph: NodeGraph;
          refreshBucketDelay?: number;
          refreshBucketDelayJitter?: number;
          retrySeedConnectionsDelay?: number;
          sigchain: Sigchain;
          taskManager: TaskManager;
      }
      • Optional connectionConnectTimeoutTime?: number
      • db: DB
      • gestaltGraph: GestaltGraph
      • keyRing: KeyRing
      • Optional logger?: Logger
      • nodeConnectionManager: NodeConnectionManager
      • nodeGraph: NodeGraph
      • Optional refreshBucketDelay?: number
      • Optional refreshBucketDelayJitter?: number
      • Optional retrySeedConnectionsDelay?: number
      • sigchain: Sigchain
      • taskManager: TaskManager

    Returns NodeManager

Properties

[initLock]: RWLockWriter
basePath: string = ...
checkSeedConnectionsHandler: TaskHandler = ...
checkSeedConnectionsHandlerId: TaskHandlerId = ...
connectionConnectTimeoutTime: number

Time used to establish NodeConnection

db: DB
gcBucketHandler: TaskHandler = ...
gcBucketHandlerId: TaskHandlerId = ...
gestaltGraph: GestaltGraph
keyRing: KeyRing
logger: Logger
nodeConnectionManager: NodeConnectionManager
nodeGraph: NodeGraph
pendingNodes: Map<number, Map<string, NodeAddress>> = ...
pingAndSetNodeHandler: TaskHandler = ...
pingAndSetNodeHandlerId: TaskHandlerId = ...
refreshBucketDelay: number
refreshBucketDelayJitter: number
refreshBucketHandler: TaskHandler = ...
refreshBucketHandlerId: TaskHandlerId = ...
retrySeedConnectionsDelay: number
sigchain: Sigchain
taskManager: TaskManager

Accessors

  • get [eventHandled](): ReadonlyWeakSet<Event>
  • Returns ReadonlyWeakSet<Event>

  • get [eventHandlers](): ReadonlyMap<string, Set<EventHandlerInfo>>
  • Returns ReadonlyMap<string, Set<EventHandlerInfo>>

  • get [eventTarget](): EventTarget
  • Returns EventTarget

  • get [handleEventError](): ((evt) => void)
  • Returns ((evt) => void)

      • (evt): void
      • Parameters

        • evt: EventError

        Returns void

  • get [running](): boolean
  • Returns boolean

  • get [statusP](): Promise<Status>
  • Returns Promise<Status>

  • get [status](): Status
  • Returns Status

Methods

  • Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optional options: boolean | AddEventListenerOptions

    Returns void

  • Parameters

    • bucketIndex: number
    • nodeId: NodeId
    • nodeAddress: NodeAddress
    • block: boolean = false
    • pingTimeoutTime: number = ...
    • ctx: ContextTimed
    • Optional tran: DBTransaction

    Returns Promise<void>

  • Call this function upon receiving a "claim node request" notification from another node.

    Parameters

    • targetNodeId: NodeId
    • Optional tran: DBTransaction
    • Optional ctx: ContextTimed

    Returns Promise<void>

  • Parameters

    • event: Event

    Returns boolean

  • Parameters

    • bucketIndex: number
    • Optional pingTimeoutTime: number
    • Optional ctx: Partial<ContextTimed>
    • Optional tran: DBTransaction

    Returns PromiseCancellable<void>

  • Gets the specified bucket from the NodeGraph

    Parameters

    • bucketIndex: number
    • Optional tran: DBTransaction

    Returns Promise<undefined | NodeBucket>

  • Retrieves the node Address from the NodeGraph

    Parameters

    • nodeId: NodeId

      node ID of the target node

    • tran: DBTransaction

    Returns Promise<undefined | NodeAddress>

    Node Address of the target node

  • Determines whether a node ID -> node address mapping exists in the NodeGraph

    Parameters

    • targetNodeId: NodeId

      the node ID of the node to find

    • tran: DBTransaction

    Returns Promise<boolean>

    true if the node exists in the table, false otherwise

  • Determines whether a node in the Polykey network is online.

    Parameters

    • nodeId: NodeId

      NodeId of the node we're pinging

    • Optional address: NodeAddress

      Optional Host and Port we want to ping

    • Optional ctx: Partial<ContextTimedInput>

    Returns PromiseCancellable<boolean>

    true if online, false if offline

  • Kademlia refresh bucket operation. It picks a random node within a bucket and does a search for that node. Connections during the search will share node information with other nodes.

    Parameters

    • bucketIndex: number
    • Optional pingTimeoutTime: number
    • Optional ctx: Partial<ContextTimed>

    Returns PromiseCancellable<void>

  • Parameters

    • type: string
    • callback: null | EventListenerOrEventListenerObject
    • Optional options: boolean | EventListenerOptions

    Returns void

  • Connects to the target node, and retrieves its sigchain data. Verifies and returns the decoded chain as ChainData. Note: this will drop any unverifiable claims. For node1 -> node2 claims, the verification process also involves connecting to node2 to verify the claim (to retrieve its signing public key).

    Parameters

    • targetNodeId: NodeId

      Id of the node to connect request the chain data of.

    • Optional claimId: ClaimId

      If set then we get the claims newer that this claim Id.

    • Optional ctx: Partial<ContextTimed>

    Returns PromiseCancellable<Record<ClaimId, SignedClaim>>

  • To be called on key renewal. Re-orders all nodes in all buckets with respect to the new node ID.

    Returns Promise<void>

  • Adds a node to the node graph. This assumes that you have already authenticated the node Updates the node if the node already exists This operation is blocking by default - set block 2qto false to make it non-blocking

    Parameters

    • nodeId: NodeId

      Id of the node we wish to add

    • nodeAddress: NodeAddress

      Expected address of the node we want to add

    • Optional block: boolean

      When true it will wait for any garbage collection to finish before returning.

    • Optional force: boolean

      Flag for if we want to add the node without authenticating or if the bucket is full. This will drop the oldest node in favor of the new.

    • Optional pingTimeoutTime: number

      Timeout for each ping operation during garbage collection.

    • Optional ctx: Partial<ContextTimed>
    • Optional tran: DBTransaction

    Returns PromiseCancellable<void>

  • Perform an initial database synchronisation: get k of the closest nodes from each seed node and add them to this database Establish a connection to each node before adding it By default this operation is blocking, set block to false to make it non-blocking

    Parameters

    • Optional block: boolean
    • Optional pingTimeoutTime: number
    • Optional ctx: Partial<ContextTimedInput>

    Returns PromiseCancellable<void>

  • Removes a node from the NodeGraph

    Parameters

    • nodeId: NodeId
    • tran: DBTransaction

    Returns Promise<void>

  • Parameters

    • bucketIndex: number
    • delay: number = ...
    • lazy: boolean = true
    • Optional tran: DBTransaction

    Returns Promise<Task>

Generated using TypeDoc