The NodesModule class serves as a module for node-related functionality, for example, checking the health of a node.

Constructors

Properties

Methods

Constructors

Properties

blocksModule: BlocksModule

Methods

  • Checks the health of a node using the following algorithm:

    1. Make an HTTP GET request to retrieve the last block timestamp.
    2. Calculates the difference between the current time and the last block timestamp.
    3. If the difference is less than the tolerance, the node is healthy. Note, we could also check '/node/network/peers since' but the difficulty with this approach is if you consider a scenario where the node is connected to 20+ peers, which is healthy, and it receives the new blocks as expected. But what if the node's disk is full, and it's not writing the new blocks to its database? In this case the node is off-sync even though it's technically alive and connected

    Returns Promise<boolean>

    A boolean indicating whether the node is healthy.