nxt.peer

## Interface Peer

-     public interface Peer

  Peer network node

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Interface and Description
    --- | ---
    `static class` | `Peer.BlockchainState`
    `static class` | `Peer.Service` Peer services
    `static class` | `Peer.State` Peer state

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `blacklist(java.lang.Exception cause)` Blacklist the peer
    `void` | `blacklist(java.lang.String cause)` Blacklist the peer
    `void` | `connectPeer()` Connect the peer
    `void` | `disconnectPeer()` Disconnect the peer
    `java.lang.String` | `getAnnouncedAddress()` Get the announced address
    `int` | `getApiPort()` Get the open API port
    `int` | `getApiServerIdleTimeout()`
    `int` | `getApiSSLPort()` Get the open SSL port
    `java.lang.String` | `getApplication()` Get the application name
    `java.lang.String` | `getBlacklistingCause()` Get the blacklist reason
    `Peer.BlockchainState` | `getBlockchainState()`
    `java.util.Set<APIEnum>` | `getDisabledAPIs()`
    `long` | `getDownloadedVolume()` Get the download volume
    `java.lang.String` | `getHost()` Get the peer host address
    `int` | `getLastConnectAttempt()` Get the time of the last connect attempt
    `int` | `getLastUpdated()` Get the time when the last message was received from the peer
    `java.lang.StringBuilder` | `getPeerApiUri()`
    `java.lang.String` | `getPlatform()` Get the application platform
    `int` | `getPort()` Get the peer port
    `java.lang.String` | `getSoftware()` Get the software description as 'name(version)@platform'
    `Peer.State` | `getState()` Get the peer state
    `long` | `getUploadedVolume()` Get the upload volume
    `java.lang.String` | `getVersion()` Get the application version
    `boolean` | `isApiConnectable()`
    `boolean` | `isBlacklisted()` Check if peer is blacklisted
    `boolean` | `isInbound()` Check if this is an inbound connection
    `boolean` | `isOpenAPI()`
    `boolean` | `providesService(Peer.Service service)` Check if the peer provides the specified service
    `boolean` | `providesServices(long services)` Check if the peer provides the specifies services
    `void` | `sendMessage(NetworkMessage message)` Send an asynchronous message
    `NetworkMessage` | `sendRequest(NetworkMessage message)` Send a request and wait for a response
    `boolean` | `shareAddress()` Check if address should be shared
    `void` | `unBlacklist()` Unblacklist the peer

- - ### Method Detail

    - #### getState

          Peer.State getState()

      Get the peer state
      Returns:
        Current state

    - #### getHost

          java.lang.String getHost()

      Get the peer host address
      Returns:
        Host address

    - #### getAnnouncedAddress

          java.lang.String getAnnouncedAddress()

      Get the announced address
      Returns:
        Announced address

    - #### getDownloadedVolume

          long getDownloadedVolume()

      Get the download volume
      Returns:
        Download volume

    - #### getUploadedVolume

          long getUploadedVolume()

      Get the upload volume
      Returns:
        Upload volume

    - #### getApplication

          java.lang.String getApplication()

      Get the application name
      Returns:
        Application name or null

    - #### getVersion

          java.lang.String getVersion()

      Get the application version
      Returns:
        Application version or null

    - #### getPlatform

          java.lang.String getPlatform()

      Get the application platform
      Returns:
        Application platform or null

    - #### getSoftware

          java.lang.String getSoftware()

      Get the software description as 'name(version)@platform'
      Returns:
        Software description

    - #### getPort

          int getPort()

      Get the peer port
      Returns:
        Peer port or 0

    - #### getApiPort

          int getApiPort()

      Get the open API port
      Returns:
        API port or 0

    - #### getApiSSLPort

          int getApiSSLPort()

      Get the open SSL port
      Returns:
        SSL port or 0

    - #### shareAddress

          boolean shareAddress()

      Check if address should be shared
      Returns:
        TRUE if address should be shared

    - #### getDisabledAPIs

          java.util.Set<APIEnum> getDisabledAPIs()

    - #### getApiServerIdleTimeout

          int getApiServerIdleTimeout()

    - #### getBlockchainState

          Peer.BlockchainState getBlockchainState()

    - #### isBlacklisted

          boolean isBlacklisted()

      Check if peer is blacklisted
      Returns:
        TRUE if peer is blacklisted

    - #### getBlacklistingCause

          java.lang.String getBlacklistingCause()

      Get the blacklist reason
      Returns:
        Blacklist reason

    - #### connectPeer

          void connectPeer()

      Connect the peer

    - #### disconnectPeer

          void disconnectPeer()

      Disconnect the peer

    - #### blacklist

          void blacklist(java.lang.Exception cause)

      Blacklist the peer
      Parameters:
        `cause` - Exception causing the blacklist

    - #### blacklist

          void blacklist(java.lang.String cause)

      Blacklist the peer
      Parameters:
        `cause` - Blacklist reason

    - #### unBlacklist

          void unBlacklist()

      Unblacklist the peer

    - #### getLastUpdated

          int getLastUpdated()

      Get the time when the last message was received from the peer
      Returns:
        Epoch time

    - #### getLastConnectAttempt

          int getLastConnectAttempt()

      Get the time of the last connect attempt
      Returns:
        Epoch time

    - #### isInbound

          boolean isInbound()

      Check if this is an inbound connection
      Returns:
        TRUE if this is an inbound connection

    - #### providesService

          boolean providesService(Peer.Service service)

      Check if the peer provides the specified service
      Parameters:
        `service` - Service
      Returns:
        TRUE if the service is provided

    - #### isOpenAPI

          boolean isOpenAPI()

    - #### isApiConnectable

          boolean isApiConnectable()

    - #### getPeerApiUri

          java.lang.StringBuilder getPeerApiUri()

    - #### providesServices

          boolean providesServices(long services)

      Check if the peer provides the specifies services
      Parameters:
        `services` - Services as a bit map
      Returns:
        TRUE if the services are provided

    - #### sendMessage

          void sendMessage(NetworkMessage message)

      Send an asynchronous message
      Parameters:
        `message` - Network message

    - #### sendRequest

          NetworkMessage sendRequest(NetworkMessage message)

      Send a request and wait for a response
      Parameters:
        `message` - Request message
      Returns:
        Response message or null if there is no response