44
55import java .util .concurrent .ExecutorService ;
66import java .util .concurrent .LinkedBlockingDeque ;
7+ import java .util .concurrent .TimeUnit ;
78import java .util .concurrent .atomic .AtomicLong ;
89import javax .annotation .PostConstruct ;
910import javax .annotation .PreDestroy ;
1011import lombok .extern .slf4j .Slf4j ;
12+ import org .checkerframework .checker .nullness .qual .NonNull ;
1113import org .springframework .beans .factory .annotation .Autowired ;
1214import org .springframework .context .annotation .Condition ;
1315import org .springframework .context .annotation .ConditionContext ;
2527import org .tron .protos .Protocol .Block ;
2628
2729@ Slf4j (topic = "app" )
28- @ Conditional (value = { SolidityNode .SolidityCondition .class } )
30+ @ Conditional (SolidityNode .SolidityCondition .class )
2931@ Component
3032public class SolidityNode {
3133
@@ -109,8 +111,15 @@ private void getBlock() {
109111 private void processSolidityBlock () {
110112 while (flag ) {
111113 try {
112- Block block = blockQueue .take ();
114+ Block block = blockQueue .poll (exceptionSleepTime , TimeUnit .MILLISECONDS );
115+ if (block == null ) {
116+ continue ;
117+ }
113118 loopProcessBlock (block );
119+ } catch (InterruptedException e ) {
120+ Thread .currentThread ().interrupt ();
121+ logger .info ("processSolidityBlock interrupted." );
122+ return ;
114123 } catch (Exception e ) {
115124 logger .error (e .getMessage ());
116125 sleep (exceptionSleepTime );
@@ -196,9 +205,11 @@ private void resolveCompatibilityIssueIfUsingFullNodeDatabase() {
196205 }
197206
198207 static class SolidityCondition implements Condition {
208+
199209 @ Override
200- public boolean matches (ConditionContext context , AnnotatedTypeMetadata metadata ) {
210+ public boolean matches (@ NonNull ConditionContext context ,
211+ @ NonNull AnnotatedTypeMetadata metadata ) {
201212 return Args .getInstance ().isSolidityNode ();
202213 }
203214 }
204- }
215+ }
0 commit comments