mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-07 06:44:16 +00:00
Fix PeerGroup.setMaxConnections for values less than 4. Resolve issue 97
This commit is contained in:
parent
b7065f3f32
commit
82070afd24
@ -151,6 +151,7 @@ public class PeerGroup {
|
||||
* @param maxConnections the maximum number of peer connections that this group will try to make.
|
||||
*/
|
||||
public synchronized void setMaxConnections(int maxConnections) {
|
||||
peerPool.setCorePoolSize(Math.min(maxConnections, DEFAULT_CONNECTIONS));
|
||||
peerPool.setMaximumPoolSize(maxConnections);
|
||||
}
|
||||
|
||||
|
@ -166,6 +166,7 @@ public class PeerGroupTest extends TestWithNetworkConnections {
|
||||
inv.addItem(new InventoryItem(InventoryItem.Type.Block, b3.getHash()));
|
||||
n1.inbound(inv);
|
||||
// Peer creates a getdata message.
|
||||
@SuppressWarnings("unused")
|
||||
GetDataMessage getdata = (GetDataMessage) n1.outbound();
|
||||
// We hand back the first block.
|
||||
n1.inbound(b1);
|
||||
@ -180,4 +181,12 @@ public class PeerGroupTest extends TestWithNetworkConnections {
|
||||
conn.disconnect();
|
||||
disconnectedPeers.take();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetMaximumConnections() {
|
||||
peerGroup.setMaxConnections(1);
|
||||
peerGroup.setMaxConnections(4);
|
||||
peerGroup.setMaxConnections(10);
|
||||
peerGroup.setMaxConnections(1);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user