Skip to content

Commit

Permalink
PeerAddress.hostname: fix probuf serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarguindzberg committed Sep 30, 2020
1 parent 9cdd3b4 commit 4b5f20f
Show file tree
Hide file tree
Showing 5 changed files with 280 additions and 91 deletions.
12 changes: 12 additions & 0 deletions core/src/main/java/org/bitcoinj/core/PeerAddress.java
Expand Up @@ -156,6 +156,18 @@ public PeerAddress(NetworkParameters params, String hostname, int port) {
this.services = BigInteger.ZERO;
}

/**
* Construct a peer address from a memorized or hardcoded hostname.
*/
public PeerAddress(NetworkParameters params, String hostname, int port, int protocolVersion, BigInteger services) {
super(params);
this.hostname = hostname;
this.port = port;
this.protocolVersion = protocolVersion;
this.services = services;
length = isSerializeTime() ? MESSAGE_SIZE : MESSAGE_SIZE - 4;
}

public static PeerAddress localhost(NetworkParameters params) {
return new PeerAddress(params, InetAddress.getLoopbackAddress(), params.getPort());
}
Expand Down

0 comments on commit 4b5f20f

Please sign in to comment.