nxt.peer

## Class NetworkMessage.BlocksMessage

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

- Enclosing class:
    NetworkMessage

      public static class NetworkMessage.BlocksMessage
      extends NetworkMessage

  The Blocks message is returned in response to the GetBlock and GetNextBlocks message. The message identifier is obtained from the request message.
  - Message identifier (long)
  - Block list

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class nxt.peer.NetworkMessage

      `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`

  - ### Field Summary

    - ### Fields inherited from class nxt.peer.NetworkMessage

      `MAX_ARRAY_LENGTH, MAX_LIST_SIZE, messageId`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `BlocksMessage(long messageId, Block block, byte[] excludedTransactions)` Construct a Blocks message
    `BlocksMessage(long messageId, java.util.List<? extends Block> blocks)` Construct a Blocks message

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected NetworkMessage` | `constructMessage(java.nio.ByteBuffer bytes)` Construct the message from the message bytes
    `Block` | `getBlock(java.util.List<Transaction> excludedTransactions)` Get the blocks This method must be used if transactions were excluded in the GetBlock message
    `int` | `getBlockCount()` Get the number of blocks
    `java.util.List<Block>` | `getBlocks()` Get the blocks This method cannot be used if transactions were excluded in the GetBlock message

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

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

- - ### Constructor Detail

    - #### BlocksMessage

          public BlocksMessage(long messageId,
                               java.util.List<? extends Block> blocks)

      Construct a Blocks message
      Parameters:
        `messageId` - Message identifier
        `blocks` - Block list

    - #### BlocksMessage

          public BlocksMessage(long messageId,
                               Block block,
                               byte[] excludedTransactions)

      Construct a Blocks message
      Parameters:
        `messageId` - Message identifier
        `block` - Block
        `excludedTransactions` - transactions to exclude

  - ### Method Detail

    - #### constructMessage

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

      Construct the message from the message bytes
      Overrides:
        `constructMessage` in class `NetworkMessage`
      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

    - #### getBlockCount

          public int getBlockCount()

      Get the number of blocks
      Returns:
        Number of blocks

    - #### getBlocks

          public java.util.List<Block> getBlocks()
                                          throws NxtException.NotValidException

      Get the blocks This method cannot be used if transactions were excluded in the GetBlock message
      Returns:
        Block list
      Throws:
        `NxtException.NotValidException` - Block is not valid

    - #### getBlock

          public Block getBlock(java.util.List<Transaction> excludedTransactions)
                         throws NxtException.NotValidException

      Get the blocks This method must be used if transactions were excluded in the GetBlock message
      Parameters:
        `excludedTransactions` - Transactions that were excluded from the blocks
      Returns:
        Block list
      Throws:
        `NxtException.NotValidException` - Block is not valid