Package com.privatechain.network.peer
Class Peer.Builder
java.lang.Object
com.privatechain.network.peer.Peer.Builder
- Enclosing class:
Peer
Fluent builder for
Peer.
Peer peer = Peer.builder()
.nodeId("ab12cd...")
.host("10.0.0.5")
.port(8545)
.build();
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds and returns aPeer.Sets the hostname or IP address of the peer.Sets the last-seen timestamp.Sets the stable logical identifier for the peer.port(int port) Sets the TCP port.publicKeyHex(String publicKeyHex) Sets the hex-encoded secp256k1 public key.
-
Method Details
-
nodeId
Sets the stable logical identifier for the peer.- Parameters:
nodeId- non-null, non-blank node ID- Returns:
- this builder
-
host
Sets the hostname or IP address of the peer.- Parameters:
host- non-null, non-blank host string- Returns:
- this builder
-
port
Sets the TCP port.- Parameters:
port- port in [1024, 65535]- Returns:
- this builder
-
publicKeyHex
Sets the hex-encoded secp256k1 public key.- Parameters:
publicKeyHex- hex-encoded key; may be null- Returns:
- this builder
-
lastSeen
Sets the last-seen timestamp.- Parameters:
lastSeen- UTC instant; may be null for new peers- Returns:
- this builder
-
build
Builds and returns aPeer.- Returns:
- new
Peerinstance - Throws:
NullPointerException- if nodeId or host is nullIllegalArgumentException- if nodeId or host is blank, or port is out of range
-