Skip to content

Commit

Permalink
mdf nodemanager change active peer init time
Browse files Browse the repository at this point in the history
  • Loading branch information
xxo1shine committed Mar 30, 2018
1 parent 7829583 commit 86d120f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
16 changes: 12 additions & 4 deletions src/main/java/org/tron/common/overlay/discover/NodeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ public void run() {

this.pongTimer = Executors.newSingleThreadScheduledExecutor();

for (Node node : args.getNodeActive()) {
getNodeHandler(node).getNodeStatistics().setPredefined(true);
}

}

public ScheduledExecutorService getPongTimer() {
Expand Down Expand Up @@ -132,9 +130,19 @@ public void run() {
for (Node node : bootNodes) {
getNodeHandler(node);
}

for (Node node : args.getNodeActive()) {
getNodeHandler(node).getNodeStatistics().setPredefined(true);
}
}
}

public boolean isNodeAlive(NodeHandler nodeHandler){
return nodeHandler.state.equals(State.Alive) ||
nodeHandler.state.equals(State.Active) ||
nodeHandler.state.equals(State.EvictCandidate);
}

private void dbRead() {
Set<Node> Nodes = this.dbManager.readNeighbours();
logger.info("Reading Node statistics from PeersStore: " + Nodes.size() + " nodes.");
Expand All @@ -145,7 +153,7 @@ private void dbWrite() {
Set<Node> batch = new HashSet<>();
synchronized (this) {
for (NodeHandler nodeHandler: nodeHandlerMap.values()){
if (!nodeHandler.state.equals(NodeHandler.State.Dead)) {
if (isNodeAlive(nodeHandler)) {
batch.add(nodeHandler.getNode());
}
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/tron/common/overlay/server/SyncPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ public boolean test(NodeHandler handler) {

//TODO: use reputation sysytem

if (handler.getState().equals(NodeHandler.State.Discovered) ||
handler.getState().equals(NodeHandler.State.Dead) ||
handler.getState().equals(NodeHandler.State.NonActive)){
if (!nodeManager.isNodeAlive(handler)){
return false;
}

Expand Down

0 comments on commit 86d120f

Please sign in to comment.