Package org.drasyl.peer
Class PeersManager
- java.lang.Object
-
- org.drasyl.peer.PeersManager
-
public class PeersManager extends Object
This class contains information about other peers. This includes the public keys, available interfaces, connections or relations (e.g. direct/relayed connection, super peer, child, grandchild). Before a relation is set for a peer, it must be ensured that its information is available. Likewise, the information may not be removed from a peer if the peer still has a relationThis class is optimized for concurrent access and is thread-safe.
-
-
Constructor Summary
Constructors Constructor Description PeersManager(Consumer<Event> eventConsumer)
-
Method Summary
-
-
-
Method Detail
-
getPeers
public Map<CompressedPublicKey,PeerInformation> getPeers()
-
getChildrenAndGrandchildren
public Map<CompressedPublicKey,PeerInformation> getChildrenAndGrandchildren()
-
getGrandchildrenRoutes
public Map<CompressedPublicKey,CompressedPublicKey> getGrandchildrenRoutes()
- Returns:
- a map with the routes of our grandchildren
-
getSuperPeer
public Triple<CompressedPublicKey,PeerInformation,Set<Path>> getSuperPeer()
- Returns:
- public key and information about Super Peer. If no Super Peer is defined, then
null
is returned
-
getSuperPeerKey
public CompressedPublicKey getSuperPeerKey()
-
getChildrenKeys
public Set<CompressedPublicKey> getChildrenKeys()
-
getPeer
public Pair<PeerInformation,Set<Path>> getPeer(CompressedPublicKey publicKey)
-
setPeerInformationAndAddPath
public void setPeerInformationAndAddPath(CompressedPublicKey publicKey, PeerInformation peerInformation, Path path)
-
setPeerInformation
public void setPeerInformation(CompressedPublicKey publicKey, PeerInformation peerInformation)
-
addPeer
public void addPeer(CompressedPublicKey publicKey)
-
removePath
public void removePath(CompressedPublicKey publicKey, Path path)
-
addGrandchildrenRoute
public void addGrandchildrenRoute(CompressedPublicKey grandchildren, CompressedPublicKey children)
-
removeGrandchildrenRoute
public void removeGrandchildrenRoute(CompressedPublicKey grandchildren)
-
unsetSuperPeer
public void unsetSuperPeer()
-
unsetSuperPeerAndRemovePath
public void unsetSuperPeerAndRemovePath(Path path)
-
setPeerInformationAndAddPathAndSetSuperPeer
public void setPeerInformationAndAddPathAndSetSuperPeer(CompressedPublicKey publicKey, PeerInformation peerInformation, Path path)
-
removeChildrenAndPath
public void removeChildrenAndPath(CompressedPublicKey publicKey, Path path)
-
setPeerInformationAndAddPathAndChildren
public void setPeerInformationAndAddPathAndChildren(CompressedPublicKey publicKey, PeerInformation peerInformation, Path path)
-
-