diff --git a/README.md b/README.md index fc178e540..1e9050155 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,13 @@ This repository, heraj is java implementation for hera. ## Lastest -v0.10.0 +v0.11.0 -build with aergo-protobuf v0.10.0 +build with aergo-protobuf v0.11.0 ## Compatibility -* Aergo : v0.10.x +* Aergo : v0.11.x * Java : JDK 6 or higher * Android : Android 3.0 (API 11) or higher @@ -47,17 +47,17 @@ If you just want a minimum one, use `heraj-transport`. Or need more feature, use io.aergo heraj-transport - 0.10.0 + 0.11.0 io.aergo heraj-wallet - 0.10.0 + 0.11.0 io.aergo heraj-smart-contract - 0.10.0 + 0.11.0 ``` @@ -72,9 +72,9 @@ repositories { ... dependencies { - implementation 'io.aergo:heraj-transport:0.10.0' - implementation 'io.aergo:heraj-wallet:0.10.0' - implementation 'io.aergo:heraj-smart-contract:0.10.0' + implementation 'io.aergo:heraj-transport:0.11.0' + implementation 'io.aergo:heraj-wallet:0.11.0' + implementation 'io.aergo:heraj-smart-contract:0.11.0' } ``` diff --git a/examples/src/main/java/hera/example/highlevel/BlockLookup.java b/examples/src/main/java/hera/example/highlevel/BlockLookup.java index 47bd9e48a..1016e2653 100644 --- a/examples/src/main/java/hera/example/highlevel/BlockLookup.java +++ b/examples/src/main/java/hera/example/highlevel/BlockLookup.java @@ -26,15 +26,15 @@ protected void blockLookup() { final BlockHash bestHash = wallet.getBestBlockHash(); final long bestHeight = wallet.getBestBlockHeight(); - // lookup block by best block hash + // query block by best block hash final Block blockByHash = wallet.getBlock(bestHash); System.out.println("Block by hash: " + blockByHash); - // lookup block by best height + // query block by best height final Block blockByHeight = wallet.getBlock(bestHeight); System.out.println("Block by height: " + blockByHeight); - // lookup previous block by hash + // query previous block by hash final Block previousBlock = wallet.getBlock(blockByHash.getPreviousHash()); System.out.println("Previous block: " + previousBlock); @@ -52,16 +52,24 @@ protected void blockHeaderLookup() { // get best block hash, height final BlockHash bestHash = wallet.getBestBlockHash(); - final Block block = wallet.getBlock(bestHash); + final long bestHeight = wallet.getBestBlockHeight(); + + // query block header corresponding to the block hash + final BlockHeader blockHeaderByHash = wallet.getBlockHeader(bestHash); + System.out.println("Block header by hash: " + blockHeaderByHash); + + // query block header corresponding to the block hash + final BlockHeader blockHeaderByHeight = wallet.getBlockHeader(bestHeight); + System.out.println("Block header by height: " + blockHeaderByHeight); - // lookup 10 block headers starting from best block backward with best block hash + // query 10 block headers starting from best block backward with best block hash final List blockHeadersByHash = - wallet.listBlockHeaders(block.getHash(), 10); + wallet.listBlockHeaders(bestHash, 10); System.out.println("Block headers by hash: " + blockHeadersByHash); - // lookup 10 block headers starting from best block backward with best block height + // query 10 block headers starting from best block backward with best block height final List blockHeadersByHeight = - wallet.listBlockHeaders(block.getBlockNumber(), 10); + wallet.listBlockHeaders(bestHeight, 10); System.out.println("Block headers by height: " + blockHeadersByHeight); // close the client diff --git a/examples/src/main/java/hera/example/highlevel/SendAergo.java b/examples/src/main/java/hera/example/highlevel/SendAergo.java index c66991a69..5d408e787 100644 --- a/examples/src/main/java/hera/example/highlevel/SendAergo.java +++ b/examples/src/main/java/hera/example/highlevel/SendAergo.java @@ -69,11 +69,12 @@ protected void sendAergoWithSecure() throws Exception { .withNonBlockingConnect() .build(WalletType.Secure); - // bind keystore - final KeyStore keyStore = KeyStore.getInstance("JKS"); // here, make a new keystore // if exists, load with input stream and password + final KeyStore keyStore = KeyStore.getInstance("JKS"); keyStore.load(null, null); + + // bind keystore wallet.bindKeyStore(keyStore); // create an account diff --git a/examples/src/main/java/hera/example/lowlevel/BlockLookup.java b/examples/src/main/java/hera/example/lowlevel/BlockLookup.java index 510944f16..aef182e1f 100644 --- a/examples/src/main/java/hera/example/lowlevel/BlockLookup.java +++ b/examples/src/main/java/hera/example/lowlevel/BlockLookup.java @@ -5,6 +5,7 @@ package hera.example.lowlevel; import hera.api.model.Block; +import hera.api.model.BlockHash; import hera.api.model.BlockHeader; import hera.api.model.BlockchainStatus; import hera.client.AergoClient; @@ -21,18 +22,18 @@ protected void blockLookup() { .withNonBlockingConnect() .build(); - // lookup current blockchain status + // query current blockchain status final BlockchainStatus status = aergoClient.getBlockchainOperation().getBlockchainStatus(); - // lookup block by best block hash + // query block by best block hash final Block blockByHash = aergoClient.getBlockOperation().getBlock(status.getBestBlockHash()); System.out.println("Block by hash: " + blockByHash); - // lookup block by best height + // query block by best height final Block blockByHeight = aergoClient.getBlockOperation().getBlock(status.getBestHeight()); System.out.println("Block by height: " + blockByHeight); - // lookup previous block by hash + // query previous block by hash final Block previousBlock = aergoClient.getBlockOperation().getBlock(blockByHash.getPreviousHash()); System.out.println("Previous block: " + previousBlock); @@ -48,18 +49,28 @@ protected void blockHeaderLookup() { .withNonBlockingConnect() .build(); - // lookup best block + // query best block final BlockchainStatus status = aergoClient.getBlockchainOperation().getBlockchainStatus(); - final Block block = aergoClient.getBlockOperation().getBlock(status.getBestBlockHash()); + final BlockHash bestHash = status.getBestBlockHash(); + final long bestHeight = status.getBestHeight(); - // lookup 10 block headers starting from best block backward with best block hash + // query block header corresponding to the block hash + final BlockHeader blockHeaderByHash = aergoClient.getBlockOperation().getBlockHeader(bestHash); + System.out.println("Block header by hash: " + blockHeaderByHash); + + // query block header corresponding to the block hash + final BlockHeader blockHeaderByHeight = + aergoClient.getBlockOperation().getBlockHeader(bestHeight); + System.out.println("Block header by height: " + blockHeaderByHeight); + + // query 10 block headers starting from best block backward with best block hash final List blockHeadersByHash = - aergoClient.getBlockOperation().listBlockHeaders(block.getHash(), 10); + aergoClient.getBlockOperation().listBlockHeaders(bestHash, 10); System.out.println("Block headers by hash: " + blockHeadersByHash); - // lookup 10 block headers starting from best block backward with best block height + // query 10 block headers starting from best block backward with best block height final List blockHeadersByHeight = - aergoClient.getBlockOperation().listBlockHeaders(block.getBlockNumber(), 10); + aergoClient.getBlockOperation().listBlockHeaders(bestHeight, 10); System.out.println("Block headers by height: " + blockHeadersByHeight); // close the client