7
7
import static org .tron .protos .Protocol .ReasonCode .INCOMPATIBLE_CHAIN ;
8
8
import static org .tron .protos .Protocol .ReasonCode .INCOMPATIBLE_PROTOCOL ;
9
9
10
+ import com .google .common .cache .CacheBuilder ;
10
11
import io .netty .buffer .ByteBuf ;
11
12
import io .netty .buffer .Unpooled ;
12
13
import io .netty .channel .Channel ;
19
20
import java .util .Date ;
20
21
import java .util .List ;
21
22
import java .util .concurrent .ConcurrentHashMap ;
23
+ import java .util .concurrent .TimeUnit ;
22
24
import lombok .extern .slf4j .Slf4j ;
23
25
import org .apache .commons .collections4 .map .LRUMap ;
24
26
import org .apache .commons .lang3 .ArrayUtils ;
@@ -233,8 +235,8 @@ private void validResultCloseConnect(Channel channel) throws InterruptedExceptio
233
235
finish = false ;
234
236
channel .close ();
235
237
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 ( ));
238
240
ReflectUtils .setFieldValue (pool , "activePeers" ,
239
241
Collections .synchronizedList (new ArrayList <PeerConnection >()));
240
242
ReflectUtils .setFieldValue (channelManager , "activePeers" , new ConcurrentHashMap <>());
@@ -252,8 +254,8 @@ private void validResultUnCloseConnect() throws InterruptedException {
252
254
private void clearConnect (Channel channel ) throws InterruptedException {
253
255
channel .close ();
254
256
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 ( ));
257
259
ReflectUtils .setFieldValue (pool , "activePeers" ,
258
260
Collections .synchronizedList (new ArrayList <PeerConnection >()));
259
261
ReflectUtils .setFieldValue (channelManager , "activePeers" , new ConcurrentHashMap <>());
0 commit comments