1 package org.duniter.core.client.example;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import org.duniter.core.client.config.Configuration;
26 import org.duniter.core.client.model.bma.BlockchainBlock;
27 import org.duniter.core.client.model.local.Peer;
28 import org.duniter.core.client.service.ServiceLocator;
29
30 public class Example1 {
31
32 public static void main(String[] args) {
33
34
35 String configFilename = "duniter4j-config.properties";
36 Configuration config = new Configuration(configFilename, args);
37 Configuration.setInstance(config);
38
39
40 ServiceLocator.instance().getDataContext().setAccountId(0);
41
42
43 ServiceLocator.instance().init();
44
45
46 Peer aPeer = Peer.newBuilder()
47 .setHost(config.getNodeHost())
48 .setPort(config.getNodePort())
49 .build();
50
51
52 BlockchainBlock currentBlock = ServiceLocator.instance().getBlockchainRemoteService().getCurrentBlock(aPeer);
53 System.out.println(String.format("Hello %s world !", currentBlock.getCurrency()));
54 }
55 }