Skip to content

Commit

Permalink
Add a PeerGroup.connectToLocalhost helper method.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikehearn committed May 4, 2014
1 parent 4df728a commit 28c1673
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/src/main/java/com/google/bitcoin/core/PeerGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -956,6 +956,16 @@ public Peer connectTo(InetSocketAddress address) {
return connectTo(peerAddress, true);
}

/**
* Helper for forcing a connection to localhost. Useful when using regtest mode. Returns the peer object.
*/
@Nullable
public Peer connectToLocalHost() {
final PeerAddress localhost = PeerAddress.localhost(params);
backoffMap.put(localhost, new ExponentialBackoff(peerBackoffParams));
return connectTo(localhost, true);
}

// Internal version.
@Nullable
protected Peer connectTo(PeerAddress address, boolean incrementMaxConnections) {
Expand Down

0 comments on commit 28c1673

Please sign in to comment.