Package nxt.peer
Class Peers
java.lang.Object
nxt.peer.Peers
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intCommunication log levelsstatic final intstatic final int -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddListener(Listener<Peer> listener, Peers.Event eventType) Add a peer listenerstatic booleanAdd a peer to the peer liststatic voidblacklistBundler(long accountId) Blacklist a bundlerstatic voidBroadcast our current bundler ratesstatic voidstatic voidstatic PeerfindOrCreatePeer(String announcedAddress, boolean create) Find or create a peer The announced address will be used for the host address if a new peer is createdstatic List<BundlerRate>getAllBundlerRates(long minBalance) Get all bundler ratesstatic Collection<Peer>Return all known peersstatic PeergetAnyPeer(List<? extends Peer> peerList) Get a random peer from the supplied liststatic PeergetAnyPeer(List<? extends Peer> peerList, Filter<Peer> filter) Get a random peer that satisfies the supplied filterstatic PeergetAnyPeer(Filter<Peer> filter) Get a random peer that satisfies the supplied filterReturn all connected peersstatic intstatic Peer.BlockchainStateGet the current blockchain statestatic PeerGet a list of peers satisfying the supplied filterGet a list of peers satisfying the supplied filterstatic List<Peer.Service>Return local peer servicesstatic voidinit()Initialize peer processingstatic booleanisBundlerBlacklisted(long accountId) Check if bundler is blacklistedstatic booleanisLogLevelEnabled(int logLevel) Check if the specified communication log level is enabledstatic booleanstatic booleanisOldVersion(String version, int[] minVersion) Check for an old NRS versionstatic booleanremoveListener(Listener<Peer> listener, Peers.Event eventType) Remove a peer listenerstatic booleanremovePeer(Peer peer) Remove a peer from the peer liststatic voidsendBundlerRates(Peer peer) Send our bundler rates to a new peerstatic voidsetCommunicationLogging(int logging) Set communication loggingstatic voidshutdown()Shutdown peer processing
-
Field Details
-
LOG_LEVEL_NAMES
public static final int LOG_LEVEL_NAMESCommunication log levels- See Also:
-
LOG_LEVEL_DETAILS
public static final int LOG_LEVEL_DETAILS- See Also:
-
LOG_LEVEL_TX_INVENTORY
public static final int LOG_LEVEL_TX_INVENTORY- See Also:
-
LOG_LEVELS_ALL
public static final int LOG_LEVELS_ALL- See Also:
-
-
Method Details
-
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
Add a peer listener- Parameters:
listener- ListenereventType- Listener event- Returns:
- TRUE if the listener was added
-
removeListener
Remove a peer listener- Parameters:
listener- ListenereventType- Listener event- Returns:
- TRUE if the listener was removed
-
addPeer
Add a peer to the peer list- Parameters:
peer- Peer to add- Returns:
- TRUE if this is a new peer
-
removePeer
Remove a peer from the peer list- Parameters:
peer- Peer to remove- Returns:
- TRUE if the peer was removed
-
getServices
Return local peer services- Returns:
- List of local peer services
-
findOrCreatePeer
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 addresscreate- TRUE to create the peer if it is not found- Returns:
- Peer or null if the peer could not be created
-
getPeer
-
getAnyPeer
Get a random peer that satisfies the supplied filter- Parameters:
filter- Filter- Returns:
- Selected peer or null
-
getAnyPeer
Get a random peer from the supplied list- Parameters:
peerList- Peer list- Returns:
- Selected peer or null
-
getAnyPeer
Get a random peer that satisfies the supplied filter- Parameters:
peerList- Peer listfilter- Filter or null if no filter supplied- Returns:
- Selected peer or null
-
getPeers
Get a list of peers satisfying the supplied filter- Parameters:
filter- Filter- Returns:
- List of peers
-
getPeers
Get a list of peers satisfying the supplied filter- Parameters:
filter- Filterlimit- Maximum number of peers to return- Returns:
- List of peers
-
getAllPeers
Return all known peers- Returns:
- List of known peers
-
getConnectedPeers
Return all connected peers- Returns:
- List of connected peers
-
getConnectedPeersCount
public static int getConnectedPeersCount() -
isOldVersion
Check for an old NRS version- Parameters:
version- Peer versionminVersion- Minimum acceptable version- Returns:
- TRUE if this is an old version
-
getMyBlockchainState
Get the current blockchain state- Returns:
- The blockchain state
-
getAllBundlerRates
Get all bundler rates- Parameters:
minBalance- Minimum bundler account balance- Returns:
- List of bundler rates
-
broadcastBundlerRates
public static void broadcastBundlerRates()Broadcast our current bundler rates -
sendBundlerRates
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
-