Class Peer.Builder

java.lang.Object
com.privatechain.network.peer.Peer.Builder
Enclosing class:
Peer

public static final class Peer.Builder extends Object
Fluent builder for Peer.

 Peer peer = Peer.builder()
     .nodeId("ab12cd...")
     .host("10.0.0.5")
     .port(8545)
     .build();
 
  • Method Details

    • nodeId

      public Peer.Builder nodeId(String nodeId)
      Sets the stable logical identifier for the peer.
      Parameters:
      nodeId - non-null, non-blank node ID
      Returns:
      this builder
    • host

      public Peer.Builder host(String host)
      Sets the hostname or IP address of the peer.
      Parameters:
      host - non-null, non-blank host string
      Returns:
      this builder
    • port

      public Peer.Builder port(int port)
      Sets the TCP port.
      Parameters:
      port - port in [1024, 65535]
      Returns:
      this builder
    • publicKeyHex

      public Peer.Builder publicKeyHex(String publicKeyHex)
      Sets the hex-encoded secp256k1 public key.
      Parameters:
      publicKeyHex - hex-encoded key; may be null
      Returns:
      this builder
    • lastSeen

      public Peer.Builder lastSeen(Instant lastSeen)
      Sets the last-seen timestamp.
      Parameters:
      lastSeen - UTC instant; may be null for new peers
      Returns:
      this builder
    • build

      public Peer build()
      Builds and returns a Peer.
      Returns:
      new Peer instance
      Throws:
      NullPointerException - if nodeId or host is null
      IllegalArgumentException - if nodeId or host is blank, or port is out of range