Interface P2PService

All Superinterfaces:
BesuService

public interface P2PService extends BesuService
Service to enable and disable P2P service.
  • Method Details

    • enableDiscovery

      void enableDiscovery()
      Enables P2P discovery.
    • disableDiscovery

      void disableDiscovery()
      Disables P2P discovery.
    • getPeerCount

      int getPeerCount()
      Get the number of connected peers.
      Returns:
      the number of connected peers
    • getPeerConnections

      Collection<? extends PeerConnection> getPeerConnections()
      Get all connected peer connections.
      Returns:
      list of connected peer connections
    • getMaintainedConnectionPeers

      Collection<? extends Peer> getMaintainedConnectionPeers()
      Get all maintained connection peers.
      Returns:
      list of maintained connection peers
    • subscribeConnect

      void subscribeConnect(P2PService.ConnectionListener networkSubscriber)
      Subscribe to connection events.
      Parameters:
      networkSubscriber - the subscriber to receive connection events
    • subscribeDisconnect

      void subscribeDisconnect(P2PService.DisconnectionListener networkSubscriber)
      Subscribe to disconnection events.
      Parameters:
      networkSubscriber - the subscriber to receive disconnection events
    • subscribeMessage

      void subscribeMessage(Capability capability, P2PService.MessageListener networkSubscriber)
      Subscribe to messages on a specific capability.
      Parameters:
      capability - the capability to subscribe to
      networkSubscriber - the subscriber to receive messages for the specified capability
    • send

      void send(String protocol, org.apache.tuweni.bytes.Bytes peerId, org.hyperledger.besu.datatypes.p2p.MessageData messageData) throws PeerConnection.PeerNotConnected
      Send a message to a specific peer.
      Parameters:
      protocol - the protocol to use
      peerId - the peer id to send the message to
      messageData - the message data to send
      Throws:
      PeerConnection.PeerNotConnected - if the peer is not connected
    • disconnect

      void disconnect(org.apache.tuweni.bytes.Bytes peerId)
      Disconnect from a specific peer.
      Parameters:
      peerId - the peer id to disconnect from