# Net API

To enable Net RPC API on the node, add "net" namespace in "PublicModules" in node_config.json

Definitions:

  • Node Id: A 32 bytes Ed25519 public key derived from the 64-byte private key stored in "~/.gvite/maindata/net/peerKey" or specified in "PeerKey" in node_config.json
  • Node Name: A human-readable name specified in "Identity" in node_config.json
  • Node Address: Node's IP address + port
  • Net Id: "NetID" configured in node_config.json. "1" stands for mainnet.
  • Block Propagate Latency: The time difference between the broadcast time of the snapshot block and the block timestamp. In milliseconds.
  • Reliable Peer: When "WhiteBlockList" is configured in node_config.json, for each peer whose height does not exceed the sum of 86400 and the maximum height in the list, each snapshot block in the whitelist will be checked on the peer. If the check fails, the peer is considered unreliable. Or when "BlackBlockHashList" is set, if a block in the blacklist can be obtained from the peer, the peer is also considered unreliable. All peers are reliable by default.
  • Sync Start Height: The height at which the current synchronization loop starts. The value is the current height of the node rounded down by 100 and added by 1. If the snapshot block at the height cannot be obtained from peers, the synchronizer will try 100 blocks backward again, or will start from the irreversible height of the node. For new nodes the value is 0.
  • Sync End Height: The height of the median node sorted by peer's height at which the current synchronization loop ends. For new nodes the value is 0.
  • Irreversible Height: In each round, starting from the first snapshot block height, when more than two-thirds of SBPs have produced blocks, we call the height at this block irreversible height for the round.
  • Chunk: A chunk is a continuous range of snapshot blocks represented by a starting block and an ending block.

Note: For synced nodes (state = 2), the sync start height and end height will not change.

# net_syncInfo

Get node's synchronization status

  • Parameters: none

  • Returns: SyncInfo

    • from: string Sync start height
    • to: string Sync end height
    • current: string Node's current height
    • state: uint Sync state: 0 - not start, 1 - syncing, 2 - complete, 3 - error, 4 - cancelled
    • status: string Sync state description
  • Example:

# net_syncDetail

Get node's synchronization status in detail

  • Parameters: none

  • Returns: SyncDetail

    • from: string Sync start height
    • to: string Sync end height
    • current: string Node's current height
    • state: string Sync state. This field returns the same value with status
    • status: string Sync state description
    • tasks: Array<string> Current download tasks. Only nodes in synchronising state have download tasks.
    • connections: Array<SyncConnectionStatus>
      • address: string Connected peer address, consisting of the first 16-byte of node id + "@" + node's ip address + port
      • speed: string Downloading speed from the peer
      • task: string Current download task
    • chunks: Array<SnapshotRange> Verified snapshot chunks waiting for inserting into local ledger
      • height: uint64 Snapshot block height
      • hash: hash Snapshot block hash
    • caches: Array<Segment> Unverified snapshot chunks stored in cache
      • From: uint64 Start snapshot block height
      • To: uint64 End snapshot block height
      • Hash: hash Segment hash
      • PreHash: hash Previous segment hash
      • Points: Array<HashHeight> Hash height points contained in the segment
        • height: uint64 Snapshot block height
        • hash: hash Snapshot block hash
  • Example:

# net_nodeInfo

Get the detailed information of the node and connected peers

  • Parameters: none

  • Returns: NodeInfo

    • id: string Node id
    • name: string Node name
    • netId: int Network id
    • version: int Node version. Returns 0 for all nodes.
    • address: string Node address. Not implemented. Returns empty string at the moment
    • peerCount: int Number of peers connected
    • peers: Array<PeerInfo> Peers connected
      • id: string Peer id
      • name: string Peer name
      • version: int Peer version. Returns 0 for all nodes.
      • height: int Peer's current height
      • address: string Peer's ip address + port
      • flag: byte Connect type. 0 - inbound, 1 - outbound
      • superior: bool true means the peer is an SBP
      • reliable: bool true means the peer is reliable
      • createAt : string The datetime when this peer was connected
      • readQueue: int The current message queue length to be read by the peer
      • writeQueue: int The peer's current message queue length to be written to other peers
      • peers: Array<string> List of peer ids that the peer is currently connected to
    • height: uint64 Node height
    • nodes: int Node table size. Not implemented. Returns 0 at the moment.
    • latency: Array<int> An array of 4 integers in order containing the current block broadcast latency, the average block broadcast latency within 1 hour, the average block broadcast latency within 12 hours, and the average block broadcast latency within 24 hours. In milliseconds.
    • broadCheckFailedRatio: float32 The ratio of account blocks received within 16 seconds with confirmations exceeding 100
    • server: Array<SyncConnectionStatus> Not implemented. Returns empty array at the moment.
  • Example:

# net_nodes

Get all alive peers in node table

Note: Alive peers are not connected peers. Alive peers are nodes stored in node's peer table and can be pinged through

  • Parameters: none

  • Returns:

    • Count: int Number of alive peers
    • Nodes: Array<Node>
      • id: string Node id
      • address: string Node's IP address + port
      • net: int Network id
      • ext: Array<byte> Additional message. Default is null
  • Example:

# net_peerCount

Get the number of connected peers

  • Parameters: none

  • Returns:

    • int Number of peers connected
  • Example: