Skip to content

Commit 967b629

Browse files
committed
add loadblock
1 parent 54fe08b commit 967b629

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

src/main/java/org/tron/consensus/client/Client.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class Client{
3333
client.serializer().register(GetQuery.class);
3434

3535
Collection<Address> cluster = Arrays.asList(
36-
new Address("192.168.0.107", 5000)
36+
new Address("192.168.0.109", 5000)
3737
);
3838
CompletableFuture<CopycatClient> future = client.connect(cluster);
3939
future.join();
@@ -186,21 +186,25 @@ public static void getMessage(Peer peer,String key) {
186186
thread.start();
187187
}
188188
}
189-
public static void loadBlock(Peer peer){
189+
public static void loadBlock(Peer peer) {
190190
int i = 2;
191-
boolean a = true;
192-
while(a){
191+
final boolean[] f = {true};
192+
while (f[0]) {
193193
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();
204208
}
205209
}
206210
}

0 commit comments

Comments
 (0)