nxt.peer

## Class Peers

- java.lang.Object
- - nxt.peer.Peers

-     public final class Peers
      extends java.lang.Object

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Peers.Event`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `LOG_LEVEL_DETAILS`
    `static int` | `LOG_LEVEL_NAMES` Communication log levels

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `addListener(Listener<Peer> listener, Peers.Event eventType)` Add a peer listener
    `static boolean` | `addPeer(Peer peer)` Add a peer to the peer list
    `static void` | `blacklistBundler(long accountId)` Blacklist a bundler
    `static void` | `broadcastBundlerRates()` Broadcast our current bundler rates
    `static void` | `disableNetworking()`
    `static void` | `enableNetworking()`
    `static Peer` | `findOrCreatePeer(java.lang.String announcedAddress, boolean create)` Find or create a peer The announced address will be used for the host address if a new peer is created
    `static java.util.List<BundlerRate>` | `getAllBundlerRates(long minBalance)` Get all bundler rates
    `static java.util.Collection<Peer>` | `getAllPeers()` Return all known peers
    `static Peer` | `getAnyPeer(Filter<Peer> filter)` Get a random peer that satisfies the supplied filter
    `static Peer` | `getAnyPeer(java.util.List<? extends Peer> peerList)` Get a random peer from the supplied list
    `static Peer` | `getAnyPeer(java.util.List<? extends Peer> peerList, Filter<Peer> filter)` Get a random peer that satisfies the supplied filter
    `static long` | `getBestBundlerRate(Chain childChain, long minBalance, long minFeeLimit, java.util.Set<java.lang.Long> whitelist)` Get the best bundler rate for a child chain
    `static java.util.List<BundlerRate>` | `getBestBundlerRates(long minBalance, long minFeeLimit, java.util.Set<java.lang.Long> whitelist)` Get the best bundler rates
    `static java.util.Set<java.lang.Long>` | `getBestBundlerRateWhitelist()`
    `static java.util.List<Peer>` | `getConnectedPeers()` Return all connected peers
    `static int` | `getConnectedPeersCount()`
    `static Peer.BlockchainState` | `getMyBlockchainState()` Get the current blockchain state
    `static Peer` | `getPeer(java.lang.String host)`
    `static java.util.List<Peer>` | `getPeers(Filter<Peer> filter)` Get a list of peers satisfying the supplied filter
    `static java.util.List<Peer>` | `getPeers(Filter<Peer> filter, int limit)` Get a list of peers satisfying the supplied filter
    `static java.util.List<Peer.Service>` | `getServices()` Return local peer services
    `static void` | `init()` Initialize peer processing
    `static boolean` | `isBundlerBlacklisted(long accountId)` Check if bundler is blacklisted
    `static boolean` | `isLogLevelEnabled(int logLevel)` Check if the specified communication log level is enabled
    `static boolean` | `isNetworkingEnabled()`
    `static boolean` | `isOldVersion(java.lang.String version, int[] minVersion)` Check for an old NRS version
    `static boolean` | `removeListener(Listener<Peer> listener, Peers.Event eventType)` Remove a peer listener
    `static boolean` | `removePeer(Peer peer)` Remove a peer from the peer list
    `static void` | `sendBundlerRates(Peer peer)` Send our bundler rates to a new peer
    `static void` | `setCommunicationLogging(int logging)` Set communication logging
    `static void` | `shutdown()` Shutdown peer processing

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

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

- - ### Field Detail

    - #### LOG_LEVEL_NAMES

          public static final int LOG_LEVEL_NAMES

      Communication log levels
      See Also:
        Constant Field Values

    - #### LOG_LEVEL_DETAILS

          public static final int LOG_LEVEL_DETAILS

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### getBestBundlerRateWhitelist

          public static java.util.Set<java.lang.Long> getBestBundlerRateWhitelist()

    - #### init

          public static void init()

      Initialize peer processing

    - #### shutdown

          public static void shutdown()

      Shutdown peer processing

    - #### disableNetworking

          public static void disableNetworking()

    - #### enableNetworking

          public static void enableNetworking()

    - #### isNetworkingEnabled

          public static boolean isNetworkingEnabled()

    - #### addListener

          public static boolean addListener(Listener<Peer> listener,
                                            Peers.Event eventType)

      Add a peer listener
      Parameters:
        `listener` - Listener
        `eventType` - Listener event
      Returns:
        TRUE if the listener was added

    - #### removeListener

          public static boolean removeListener(Listener<Peer> listener,
                                               Peers.Event eventType)

      Remove a peer listener
      Parameters:
        `listener` - Listener
        `eventType` - Listener event
      Returns:
        TRUE if the listener was removed

    - #### addPeer

          public static boolean addPeer(Peer peer)

      Add a peer to the peer list
      Parameters:
        `peer` - Peer to add
      Returns:
        TRUE if this is a new peer

    - #### removePeer

          public static boolean removePeer(Peer peer)

      Remove a peer from the peer list
      Parameters:
        `peer` - Peer to remove
      Returns:
        TRUE if the peer was removed

    - #### getServices

          public static java.util.List<Peer.Service> getServices()

      Return local peer services
      Returns:
        List of local peer services

    - #### findOrCreatePeer

          public static Peer findOrCreatePeer(java.lang.String announcedAddress,
                                              boolean create)

      Find or create a peer The announced address will be used for the host address if a new peer is created
      Parameters:
        `announcedAddress` - Peer announced address
        `create` - TRUE to create the peer if it is not found
      Returns:
        Peer or null if the peer could not be created

    - #### getPeer

          public static Peer getPeer(java.lang.String host)

    - #### getAnyPeer

          public static Peer getAnyPeer(Filter<Peer> filter)

      Get a random peer that satisfies the supplied filter
      Parameters:
        `filter` - Filter
      Returns:
        Selected peer or null

    - #### getAnyPeer

          public static Peer getAnyPeer(java.util.List<? extends Peer> peerList)

      Get a random peer from the supplied list
      Parameters:
        `peerList` - Peer list
      Returns:
        Selected peer or null

    - #### getAnyPeer

          public static Peer getAnyPeer(java.util.List<? extends Peer> peerList,
                                        Filter<Peer> filter)

      Get a random peer that satisfies the supplied filter
      Parameters:
        `peerList` - Peer list
        `filter` - Filter or null if no filter supplied
      Returns:
        Selected peer or null

    - #### getPeers

          public static java.util.List<Peer> getPeers(Filter<Peer> filter)

      Get a list of peers satisfying the supplied filter
      Parameters:
        `filter` - Filter
      Returns:
        List of peers

    - #### getPeers

          public static java.util.List<Peer> getPeers(Filter<Peer> filter,
                                                      int limit)

      Get a list of peers satisfying the supplied filter
      Parameters:
        `filter` - Filter
        `limit` - Maximum number of peers to return
      Returns:
        List of peers

    - #### getAllPeers

          public static java.util.Collection<Peer> getAllPeers()

      Return all known peers
      Returns:
        List of known peers

    - #### getConnectedPeers

          public static java.util.List<Peer> getConnectedPeers()

      Return all connected peers
      Returns:
        List of connected peers

    - #### getConnectedPeersCount

          public static int getConnectedPeersCount()

    - #### isOldVersion

          public static boolean isOldVersion(java.lang.String version,
                                             int[] minVersion)

      Check for an old NRS version
      Parameters:
        `version` - Peer version
        `minVersion` - Minimum acceptable version
      Returns:
        TRUE if this is an old version

    - #### getMyBlockchainState

          public static Peer.BlockchainState getMyBlockchainState()

      Get the current blockchain state
      Returns:
        The blockchain state

    - #### getBestBundlerRates

          public static java.util.List<BundlerRate> getBestBundlerRates(long minBalance,
                                                                        long minFeeLimit,
                                                                        java.util.Set<java.lang.Long> whitelist)

      Get the best bundler rates
      Parameters:
        `minBalance` - Minimum bundler effective account balance in FXT
        `minFeeLimit` - Minimum bundler remaining fee limit in FQT
        `whitelist` - If present, only rates from the whitelisted accounts will be returned
      Returns:
        List of bundler rates

    - #### getAllBundlerRates

          public static java.util.List<BundlerRate> getAllBundlerRates(long minBalance)

      Get all bundler rates
      Parameters:
        `minBalance` - Minimum bundler account balance
      Returns:
        List of bundler rates

    - #### getBestBundlerRate

          public static long getBestBundlerRate(Chain childChain,
                                                long minBalance,
                                                long minFeeLimit,
                                                java.util.Set<java.lang.Long> whitelist)

      Get the best bundler rate for a child chain
      Parameters:
        `childChain` - Child chain
        `minBalance` - Minimum bundler effective account balance in FXT
        `minFeeLimit` - Minimum bundler remaining fee limit in FQT
        `whitelist` - If present, only rates from the whitelisted accounts will be returned
      Returns:
        Best bundler rate or -1 if there are no rates

    - #### broadcastBundlerRates

          public static void broadcastBundlerRates()

      Broadcast our current bundler rates

    - #### sendBundlerRates

          public static void sendBundlerRates(Peer peer)

      Send our bundler rates to a new peer
      Parameters:
        `peer` - Peer

    - #### isBundlerBlacklisted

          public static boolean isBundlerBlacklisted(long accountId)

      Check if bundler is blacklisted
      Parameters:
        `accountId` - Bundler account
      Returns:
        TRUE if the bundler is blacklisted

    - #### blacklistBundler

          public static void blacklistBundler(long accountId)

      Blacklist a bundler
      Parameters:
        `accountId` - Bundler account

    - #### isLogLevelEnabled

          public static boolean isLogLevelEnabled(int logLevel)

      Check if the specified communication log level is enabled
      Parameters:
        `logLevel` - Communication logging level
      Returns:
        TRUE if the log level is enabled

    - #### setCommunicationLogging

          public static void setCommunicationLogging(int logging)

      Set communication logging
      Parameters:
        `logging` - Communication logging value