mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-01-31 07:12:17 +00:00
Don't increment maxConnections when using connectTo from the PeerGroup thread. Resolves issue 234.
This commit is contained in:
parent
bc3fbb1448
commit
3560d18ea2
@ -547,7 +547,7 @@ public class PeerGroup {
|
|||||||
*/
|
*/
|
||||||
private void tryNextPeer() throws InterruptedException {
|
private void tryNextPeer() throws InterruptedException {
|
||||||
PeerAddress address = inactives.take();
|
PeerAddress address = inactives.take();
|
||||||
connectTo(address.toSocketAddress());
|
connectTo(address.toSocketAddress(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -567,6 +567,11 @@ public class PeerGroup {
|
|||||||
* connection does not mean that protocol handshake has occured.
|
* connection does not mean that protocol handshake has occured.
|
||||||
*/
|
*/
|
||||||
public ChannelFuture connectTo(SocketAddress address) {
|
public ChannelFuture connectTo(SocketAddress address) {
|
||||||
|
return connectTo(address, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Internal version.
|
||||||
|
protected ChannelFuture connectTo(SocketAddress address, boolean incrementMaxConnections) {
|
||||||
ChannelFuture future = bootstrap.connect(address);
|
ChannelFuture future = bootstrap.connect(address);
|
||||||
TCPNetworkConnection.NetworkHandler networkHandler =
|
TCPNetworkConnection.NetworkHandler networkHandler =
|
||||||
(TCPNetworkConnection.NetworkHandler) future.getChannel().getPipeline().get("codec");
|
(TCPNetworkConnection.NetworkHandler) future.getChannel().getPipeline().get("codec");
|
||||||
@ -577,7 +582,8 @@ public class PeerGroup {
|
|||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
Peer peer = peerFromChannelFuture(future);
|
Peer peer = peerFromChannelFuture(future);
|
||||||
channelFutures.put(peer, future);
|
channelFutures.put(peer, future);
|
||||||
setMaxConnections(getMaxConnections() + 1);
|
if (incrementMaxConnections)
|
||||||
|
setMaxConnections(getMaxConnections() + 1);
|
||||||
}
|
}
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@ -820,7 +826,7 @@ public class PeerGroup {
|
|||||||
* <p>The transaction won't be sent until there are at least {@link com.google.bitcoin.core.PeerGroup#getMaxConnections()}
|
* <p>The transaction won't be sent until there are at least {@link com.google.bitcoin.core.PeerGroup#getMaxConnections()}
|
||||||
* active connections available.</p>
|
* active connections available.</p>
|
||||||
*/
|
*/
|
||||||
public synchronized ListenableFuture<Transaction> broadcastTransaction(final Transaction tx) {
|
public ListenableFuture<Transaction> broadcastTransaction(final Transaction tx) {
|
||||||
final SettableFuture<Transaction> future = SettableFuture.create();
|
final SettableFuture<Transaction> future = SettableFuture.create();
|
||||||
final int maxConnections = getMaxConnections();
|
final int maxConnections = getMaxConnections();
|
||||||
log.info("Waiting for {} peers ...", maxConnections);
|
log.info("Waiting for {} peers ...", maxConnections);
|
||||||
|
Loading…
Reference in New Issue
Block a user