Skip to content

Commit

Permalink
Move TaskRequestActiveNodes into P2pMgr
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandraRoatis committed Apr 22, 2020
1 parent da0cdd9 commit b875c49
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 83 deletions.
33 changes: 0 additions & 33 deletions modP2pImpl/src/org/aion/p2p/impl/TaskRequestActiveNodes.java

This file was deleted.

19 changes: 12 additions & 7 deletions modP2pImpl/src/org/aion/p2p/impl1/P2pMgr.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
import org.aion.p2p.Msg;
import org.aion.p2p.P2pConstant;
import org.aion.p2p.Ver;
import org.aion.p2p.impl.TaskRequestActiveNodes;
import org.aion.p2p.impl.TaskUPnPManager;
import org.aion.p2p.impl.comm.Node;
import org.aion.p2p.impl.comm.NodeMgr;
import org.aion.p2p.impl.zero.msg.ReqActiveNodes;
import org.aion.p2p.impl.zero.msg.ReqHandshake1;
import org.aion.p2p.impl.zero.msg.ResHandshake1;
import org.apache.commons.collections4.map.LRUMap;
Expand All @@ -44,7 +44,7 @@
public final class P2pMgr implements IP2pMgr {
private static final int DELAY_SHOW_P2P_STATUS = 10; // in seconds
private static final int DELAY_CLEAR_PEERS = 10; // in seconds
private static final int PERIOD_REQUEST_ACTIVE_NODES = 1000;
private static final int DELAY_REQUEST_ACTIVE_NODES = 1; // in seconds
private static final int PERIOD_UPNP_PORT_MAPPING = 3600000;
private static final int DELAY_CONNECT_OUTBOUND = 1; // in seconds
private static final int TIMEOUT_OUTBOUND_CONNECT = 10000; // in milliseconds
Expand Down Expand Up @@ -91,6 +91,7 @@ public final class P2pMgr implements IP2pMgr {

private static ReqHandshake1 cachedReqHandshake1;
private static ResHandshake1 cachedResHandshake1;
private static final ReqActiveNodes cachedReqActiveNodesMsg = new ReqActiveNodes();

public enum Dest {
INBOUND,
Expand Down Expand Up @@ -242,11 +243,15 @@ public void run() {
}

if (!syncSeedsOnly) {
scheduledWorkers.scheduleWithFixedDelay(
new TaskRequestActiveNodes(this, p2pLOG),
5000,
PERIOD_REQUEST_ACTIVE_NODES,
TimeUnit.MILLISECONDS);
scheduledWorkers.scheduleWithFixedDelay(() -> {
Thread.currentThread().setName("p2p-reqNodes");
INode node = getRandom();
if (node != null) {
p2pLOG.trace("TaskRequestActiveNodes: {}", node.toString());
send(node.getIdHash(), node.getIdShort(), cachedReqActiveNodesMsg);
}
},
5 * DELAY_REQUEST_ACTIVE_NODES, DELAY_REQUEST_ACTIVE_NODES, TimeUnit.SECONDS);
}

scheduledWorkers.scheduleWithFixedDelay(
Expand Down
43 changes: 0 additions & 43 deletions modP2pImpl/test/org/aion/p2p/impl/TaskRequestActiveNodesTest.java

This file was deleted.

0 comments on commit b875c49

Please sign in to comment.