77import static org .tron .protos .Protocol .ReasonCode .INCOMPATIBLE_CHAIN ;
88import static org .tron .protos .Protocol .ReasonCode .INCOMPATIBLE_PROTOCOL ;
99
10+ import com .google .common .cache .CacheBuilder ;
1011import io .netty .buffer .ByteBuf ;
1112import io .netty .buffer .Unpooled ;
1213import io .netty .channel .Channel ;
1920import java .util .Date ;
2021import java .util .List ;
2122import java .util .concurrent .ConcurrentHashMap ;
23+ import java .util .concurrent .TimeUnit ;
2224import lombok .extern .slf4j .Slf4j ;
2325import org .apache .commons .collections4 .map .LRUMap ;
2426import org .apache .commons .lang3 .ArrayUtils ;
@@ -233,8 +235,8 @@ private void validResultCloseConnect(Channel channel) throws InterruptedExceptio
233235 finish = false ;
234236 channel .close ();
235237 Thread .sleep (sleepTime );
236- ReflectUtils .setFieldValue (channelManager , "recentlyDisconnected" , Collections
237- .synchronizedMap ( new LRUMap < InetAddress , Date >( 500 ) ));
238+ ReflectUtils .setFieldValue (channelManager , "recentlyDisconnected" , CacheBuilder . newBuilder (). maximumSize ( 1000 )
239+ .expireAfterWrite ( 30 , TimeUnit . SECONDS ). recordStats (). build ( ));
238240 ReflectUtils .setFieldValue (pool , "activePeers" ,
239241 Collections .synchronizedList (new ArrayList <PeerConnection >()));
240242 ReflectUtils .setFieldValue (channelManager , "activePeers" , new ConcurrentHashMap <>());
@@ -252,8 +254,8 @@ private void validResultUnCloseConnect() throws InterruptedException {
252254 private void clearConnect (Channel channel ) throws InterruptedException {
253255 channel .close ();
254256 Thread .sleep (sleepTime );
255- ReflectUtils .setFieldValue (channelManager , "recentlyDisconnected" , Collections
256- .synchronizedMap ( new LRUMap < InetAddress , Date >( 500 ) ));
257+ ReflectUtils .setFieldValue (channelManager , "recentlyDisconnected" , CacheBuilder . newBuilder (). maximumSize ( 1000 )
258+ .expireAfterWrite ( 30 , TimeUnit . SECONDS ). recordStats (). build ( ));
257259 ReflectUtils .setFieldValue (pool , "activePeers" ,
258260 Collections .synchronizedList (new ArrayList <PeerConnection >()));
259261 ReflectUtils .setFieldValue (channelManager , "activePeers" , new ConcurrentHashMap <>());
0 commit comments