Skip to content

Commit 0e5a48f

Browse files
committed
use flag in getBlockByNum, getLastSolidityBlockNum
1 parent 62107e6 commit 0e5a48f

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

framework/src/main/java/org/tron/program/SolidityNode.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class SolidityNode {
3737

3838
private DatabaseGrpcClient databaseGrpcClient;
3939

40-
private AtomicLong ID = new AtomicLong();
40+
private final AtomicLong ID = new AtomicLong();
4141

4242
private final AtomicLong remoteBlockNum = new AtomicLong();
4343

@@ -136,7 +136,7 @@ private void loopProcessBlock(Block block) {
136136
}
137137

138138
private Block getBlockByNum(long blockNum) {
139-
while (true) {
139+
while (flag) {
140140
try {
141141
long time = System.currentTimeMillis();
142142
Block block = databaseGrpcClient.getBlock(blockNum);
@@ -154,10 +154,11 @@ private Block getBlockByNum(long blockNum) {
154154
sleep(exceptionSleepTime);
155155
}
156156
}
157+
throw new RuntimeException("SolitityNode is closing.");
157158
}
158159

159160
private long getLastSolidityBlockNum() {
160-
while (true) {
161+
while (flag) {
161162
try {
162163
long time = System.currentTimeMillis();
163164
long blockNum = databaseGrpcClient.getDynamicProperties().getLastSolidityBlockNum();
@@ -170,6 +171,7 @@ private long getLastSolidityBlockNum() {
170171
sleep(exceptionSleepTime);
171172
}
172173
}
174+
throw new RuntimeException("SolitityNode is closing.");
173175
}
174176

175177
public void sleep(long time) {

0 commit comments

Comments
 (0)