File tree Expand file tree Collapse file tree
framework/src/main/java/org/tron/core/net/service/effective Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -111,10 +111,12 @@ private void disconnectIsolated2() {
111111 return ;
112112 }
113113 logger .warn ("Node is isolated, try to disconnect from peers" );
114- int peerSize = tronNetDelegate .getActivePeer ().size ();
115114
116115 //disconnect from the node whose lastActiveTime is smallest
117- if (peerSize >= CommonParameter .getInstance ().getMinActiveConnections ()) {
116+ int activePeerSize = (int ) tronNetDelegate .getActivePeer ().stream ()
117+ .filter (peer -> peer .getChannel ().isActive ())
118+ .count ();
119+ if (activePeerSize >= CommonParameter .getInstance ().getMinActiveConnections ()) {
118120 List <PeerConnection > peers = tronNetDelegate .getActivePeer ().stream ()
119121 .filter (peer -> !peer .getChannel ().isTrustPeer ())
120122 .filter (peer -> peer .getChannel ().isActive ())
@@ -127,7 +129,7 @@ private void disconnectIsolated2() {
127129
128130 //disconnect from some passive nodes, make sure retention nodes' num <= 0.8 * maxConnection,
129131 //so new peers can come in
130- peerSize = tronNetDelegate .getActivePeer ().size ();
132+ int peerSize = tronNetDelegate .getActivePeer ().size ();
131133 int threshold = (int ) (CommonParameter .getInstance ().getMaxConnections () * retentionPercent );
132134 if (peerSize > threshold ) {
133135 int disconnectSize = peerSize - threshold ;
You can’t perform that action at this time.
0 commit comments