nxt.peer

## Class NetworkMessage

- java.lang.Object
- - nxt.peer.NetworkMessage

- Direct Known Subclasses:
    NetworkMessage.AddPeersMessage, NetworkMessage.BlockchainStateMessage, NetworkMessage.BlockIdsMessage, NetworkMessage.BlockInventoryMessage, NetworkMessage.BlocksMessage, NetworkMessage.BundlerRateMessage, NetworkMessage.CumulativeDifficultyMessage, NetworkMessage.ErrorMessage, NetworkMessage.GetBlockMessage, NetworkMessage.GetCumulativeDifficultyMessage, NetworkMessage.GetInfoMessage, NetworkMessage.GetMilestoneBlockIdsMessage, NetworkMessage.GetNextBlockIdsMessage, NetworkMessage.GetNextBlocksMessage, NetworkMessage.GetPeersMessage, NetworkMessage.GetTransactionsMessage, NetworkMessage.GetUnconfirmedTransactionsMessage, NetworkMessage.MilestoneBlockIdsMessage, NetworkMessage.TransactionsInventoryMessage, NetworkMessage.TransactionsMessage

      public abstract class NetworkMessage
      extends java.lang.Object

  NetworkMessage represents the messages exchanged between peers.

  Each network message has a common prefix followed by the message payload

  - Message name (string)
  - Protocol level (short)

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `NetworkMessage.AddPeersMessage` The AddPeers message is sent to a peer to update its peer list and it is also returned as an asynchronous response to the GetPeers message Peer list
    `static class` | `NetworkMessage.BlockchainStateMessage` The BlockchainState message is sent when blockchain state changes.
    `static class` | `NetworkMessage.BlockIdsMessage` The BlockIds message is returned in response to the GetNextBlockIds message.
    `static class` | `NetworkMessage.BlockInventoryMessage` The BlockInventory message is sent when a peer has received a new block.
    `static class` | `NetworkMessage.BlocksMessage` The Blocks message is returned in response to the GetBlock and GetNextBlocks message.
    `static class` | `NetworkMessage.BundlerRateMessage` The BundlerRate message is periodically broadcast when the peer has one or more active bundlers.
    `static class` | `NetworkMessage.CumulativeDifficultyMessage` The CumulativeDifficulty message is returned in response to the GetCumulativeDifficulty message.
    `static class` | `NetworkMessage.ErrorMessage` The Error message is returned when a error is detected while processing a request.
    `static class` | `NetworkMessage.GetBlockMessage` The GetBlock message is sent when a peer is notified that a new block is available.
    `static class` | `NetworkMessage.GetCumulativeDifficultyMessage` The GetCumulativeDifficulty message is sent to a peer to get the current blockchain status.
    `static class` | `NetworkMessage.GetInfoMessage` The GetInfo message is exchanged when a peer connection is established.
    `static class` | `NetworkMessage.GetMilestoneBlockIdsMessage` The GetMilestoneBlockIds message is sent when a peer is downloading the blockchain.
    `static class` | `NetworkMessage.GetNextBlockIdsMessage` The GetNextBlockIds message is sent when a peer is downloading the blockchain.
    `static class` | `NetworkMessage.GetNextBlocksMessage` The GetNextBlocks message is sent when a peer is downloading the blockchain.
    `static class` | `NetworkMessage.GetPeersMessage` The GetPeers message is sent to a peer to request a list of connected peers.
    `static class` | `NetworkMessage.GetTransactionsMessage` The GetTransactions message is sent to retrieve one or more transactions.
    `static class` | `NetworkMessage.GetUnconfirmedTransactionsMessage` The GetUnconfirmedTransactions message is sent to retrieve the current set of unconfirmed transactions.
    `static class` | `NetworkMessage.MilestoneBlockIdsMessage` The MilestoneBlockIds message is returned in response to the GetMilestoneBlockIds message.
    `static class` | `NetworkMessage.TransactionsInventoryMessage` The TransactionsInventory message is sent when a peer has received new transactions.
    `static class` | `NetworkMessage.TransactionsMessage` The Transactions message is returned in response to the GetTransactions and GetUnconfirmedTransactions messages.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `MAX_ARRAY_LENGTH` Maximum byte array length
    `static int` | `MAX_LIST_SIZE` Maximum list size
    `protected long` | `messageId` Message identifier

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected NetworkMessage` | `constructMessage(java.nio.ByteBuffer bytes)` Construct the message

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### MAX_ARRAY_LENGTH

          public static final int MAX_ARRAY_LENGTH

      Maximum byte array length
      See Also:
        Constant Field Values

    - #### MAX_LIST_SIZE

          public static final int MAX_LIST_SIZE

      Maximum list size
      See Also:
        Constant Field Values

    - #### messageId

          protected long messageId

      Message identifier

  - ### Method Detail

    - #### constructMessage

          protected NetworkMessage constructMessage(java.nio.ByteBuffer bytes)
                                             throws java.nio.BufferOverflowException,
                                                    java.nio.BufferUnderflowException,
                                                    nxt.peer.NetworkException

      Construct the message
      Parameters:
        `bytes` - Message bytes following the message name
      Returns:
        Message
      Throws:
        `java.nio.BufferOverflowException` - Message buffer is too small
        `java.nio.BufferUnderflowException` - Message is too short
        `NetworkException` - Message is not valid