File tree Expand file tree Collapse file tree 1 file changed +18
-14
lines changed
src/main/java/org/tron/consensus/client Expand file tree Collapse file tree 1 file changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ public class Client{
33
33
client .serializer ().register (GetQuery .class );
34
34
35
35
Collection <Address > cluster = Arrays .asList (
36
- new Address ("192.168.0.107 " , 5000 )
36
+ new Address ("192.168.0.109 " , 5000 )
37
37
);
38
38
CompletableFuture <CopycatClient > future = client .connect (cluster );
39
39
future .join ();
@@ -186,21 +186,25 @@ public static void getMessage(Peer peer,String key) {
186
186
thread .start ();
187
187
}
188
188
}
189
- public static void loadBlock (Peer peer ){
189
+ public static void loadBlock (Peer peer ) {
190
190
int i = 2 ;
191
- boolean a = true ;
192
- while ( a ) {
191
+ final boolean [] f = { true } ;
192
+ while ( f [ 0 ]) {
193
193
String block_key = "block" + i ;
194
- Object block = client .submit (new GetQuery (block_key )).join ();
195
- if (!(block == null )) {
196
- peer .addReceiveBlock (String .valueOf
197
- (block ));
198
- System .out .println (block .toString ());
199
- a = true ;
200
- i ++;
201
- }
202
- if (null == block ){
203
- a = false ;
194
+ client .submit (new GetQuery (block_key )).thenAccept ((Object block ) -> {
195
+ if (!(block == null )) {
196
+ peer .addReceiveBlock (String .valueOf
197
+ (block ));
198
+ f [0 ] = true ;
199
+ } else {
200
+ f [0 ] = false ;
201
+ }
202
+ });
203
+ i ++;
204
+ try {
205
+ Thread .sleep (3000 );
206
+ } catch (InterruptedException e ) {
207
+ e .printStackTrace ();
204
208
}
205
209
}
206
210
}
You can’t perform that action at this time.
0 commit comments