diff --git a/gradle.properties b/gradle.properties index 69d7c1d..a166eb9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group = com.bloxbean.cardano artifactId = yaci -version = 0.2.3.1-SNAPSHOT +version = 0.2.3.2-SNAPSHOT diff --git a/helper/src/integrationTest/java/com/bloxbean/cardano/yaci/helper/BlockRangeSyncIT.java b/helper/src/integrationTest/java/com/bloxbean/cardano/yaci/helper/BlockRangeSyncIT.java index 46e253e..357540f 100644 --- a/helper/src/integrationTest/java/com/bloxbean/cardano/yaci/helper/BlockRangeSyncIT.java +++ b/helper/src/integrationTest/java/com/bloxbean/cardano/yaci/helper/BlockRangeSyncIT.java @@ -1,8 +1,10 @@ package com.bloxbean.cardano.yaci.helper; import com.bloxbean.cardano.yaci.core.model.Block; +import com.bloxbean.cardano.yaci.core.model.Era; import com.bloxbean.cardano.yaci.core.protocol.chainsync.messages.Point; import com.bloxbean.cardano.yaci.helper.listener.BlockChainDataListener; +import com.bloxbean.cardano.yaci.helper.model.Transaction; import org.junit.jupiter.api.Test; import java.util.ArrayList; @@ -21,7 +23,7 @@ void fetch() throws InterruptedException { BlockRangeSync blockRangeSync = new BlockRangeSync(node, nodePort, protocolMagic); blockRangeSync.start(new BlockChainDataListener() { @Override - public void onBlock(Block block) { + public void onBlock(Era era, Block block, List transactions) { System.out.println(block.getHeader().getHeaderBody().getBlockNumber()); blocks.add(block); countDownLatch.countDown(); diff --git a/helper/src/integrationTest/java/com/bloxbean/cardano/yaci/helper/BlockSyncIT.java b/helper/src/integrationTest/java/com/bloxbean/cardano/yaci/helper/BlockSyncIT.java index 816f0c3..4b3d368 100644 --- a/helper/src/integrationTest/java/com/bloxbean/cardano/yaci/helper/BlockSyncIT.java +++ b/helper/src/integrationTest/java/com/bloxbean/cardano/yaci/helper/BlockSyncIT.java @@ -2,7 +2,6 @@ import com.bloxbean.cardano.yaci.core.common.Constants; import com.bloxbean.cardano.yaci.core.model.Block; -import com.bloxbean.cardano.yaci.core.model.BlockHeader; import com.bloxbean.cardano.yaci.core.model.Era; import com.bloxbean.cardano.yaci.core.protocol.chainsync.messages.Point; import com.bloxbean.cardano.yaci.core.protocol.chainsync.messages.Tip; @@ -28,17 +27,14 @@ void syncFromTip() throws InterruptedException { AtomicLong blockNo = new AtomicLong(); CountDownLatch countDownLatch = new CountDownLatch(1); blockSync.startSyncFromTip(new BlockChainDataListener() { - @Override - public void onBlock(Block block) { + + public void onBlock(Era era, Block block, List transactions) { System.out.println(block.getHeader().getHeaderBody().getBlockNumber()); blockNo.set(block.getHeader().getHeaderBody().getBlockNumber()); + System.out.println("# of transactions >> " + transactions.size()); countDownLatch.countDown(); } - @Override - public void onTransactions(Era era, BlockHeader blockHeader, List transactions) { - System.out.println("# of transactions >> " + transactions.size()); - } }); countDownLatch.await(60, TimeUnit.SECONDS); @@ -51,19 +47,14 @@ void syncFromPoint() throws InterruptedException { AtomicLong blockNo = new AtomicLong(); AtomicInteger noOfTxs = new AtomicInteger(); - CountDownLatch countDownLatch = new CountDownLatch(4); + CountDownLatch countDownLatch = new CountDownLatch(2); blockSync.startSync(new Point(13107195, "ad2ceec67a07069d6e9295ed2144015860602c29f42505dc6ea2f55b9fc0dd93"), new BlockChainDataListener() { @Override - public void onBlock(Block block) { + public void onBlock(Era era, Block block, List transactions) { System.out.println(block.getHeader().getHeaderBody().getBlockNumber()); if (blockNo.get() == 0) blockNo.set(block.getHeader().getHeaderBody().getBlockNumber()); - countDownLatch.countDown(); - } - - @Override - public void onTransactions(Era era, BlockHeader blockHeader, List transactions) { System.out.println("# of transactions >> " + transactions.size()); noOfTxs.set(transactions.size()); countDownLatch.countDown(); diff --git a/helper/src/main/java/com/bloxbean/cardano/yaci/helper/GenesisBlockFinder.java b/helper/src/main/java/com/bloxbean/cardano/yaci/helper/GenesisBlockFinder.java index b1969c4..8af6166 100644 --- a/helper/src/main/java/com/bloxbean/cardano/yaci/helper/GenesisBlockFinder.java +++ b/helper/src/main/java/com/bloxbean/cardano/yaci/helper/GenesisBlockFinder.java @@ -3,11 +3,12 @@ import com.bloxbean.cardano.yaci.core.model.Block; import com.bloxbean.cardano.yaci.core.model.Era; import com.bloxbean.cardano.yaci.core.model.byron.ByronEbBlock; -import com.bloxbean.cardano.yaci.core.model.byron.ByronMainBlock; import com.bloxbean.cardano.yaci.core.protocol.chainsync.messages.Point; import com.bloxbean.cardano.yaci.helper.listener.BlockChainDataListener; import com.bloxbean.cardano.yaci.helper.model.StartPoint; +import com.bloxbean.cardano.yaci.helper.model.Transaction; +import java.util.List; import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -32,7 +33,7 @@ public void onByronEbBlock(ByronEbBlock byronEbBlock) { } @Override - public void onBlock(Block block) { + public void onBlock(Era era, Block block, List transactions) { if (block.getHeader().getHeaderBody().getBlockNumber() == 0) { startPoint.setFirstBlock(new Point(block.getHeader().getHeaderBody().getSlot(), block.getHeader().getHeaderBody().getBlockHash())); startPoint.setFirstBlockEra(block.getEra()); diff --git a/helper/src/main/java/com/bloxbean/cardano/yaci/helper/listener/BlockChainDataListener.java b/helper/src/main/java/com/bloxbean/cardano/yaci/helper/listener/BlockChainDataListener.java index 3161189..d4d16ef 100644 --- a/helper/src/main/java/com/bloxbean/cardano/yaci/helper/listener/BlockChainDataListener.java +++ b/helper/src/main/java/com/bloxbean/cardano/yaci/helper/listener/BlockChainDataListener.java @@ -1,7 +1,6 @@ package com.bloxbean.cardano.yaci.helper.listener; import com.bloxbean.cardano.yaci.core.model.Block; -import com.bloxbean.cardano.yaci.core.model.BlockHeader; import com.bloxbean.cardano.yaci.core.model.Era; import com.bloxbean.cardano.yaci.core.model.byron.ByronEbBlock; import com.bloxbean.cardano.yaci.core.model.byron.ByronMainBlock; @@ -15,9 +14,8 @@ public interface BlockChainDataListener { default void onByronBlock(ByronMainBlock byronBlock) {} default void onByronEbBlock(ByronEbBlock byronEbBlock) {} - default void onBlock(Block block) {} + default void onBlock(Era era, Block block, List transactions) {} default void onRollback(Point point) {} - default void onTransactions(Era era, BlockHeader blockHeader, List transactions) {} default void batchDone() {} default void noBlockFound(Point from, Point to) {} diff --git a/helper/src/main/java/com/bloxbean/cardano/yaci/helper/listener/BlockFetchAgentListenerAdapter.java b/helper/src/main/java/com/bloxbean/cardano/yaci/helper/listener/BlockFetchAgentListenerAdapter.java index 00f8536..27531b2 100644 --- a/helper/src/main/java/com/bloxbean/cardano/yaci/helper/listener/BlockFetchAgentListenerAdapter.java +++ b/helper/src/main/java/com/bloxbean/cardano/yaci/helper/listener/BlockFetchAgentListenerAdapter.java @@ -59,8 +59,7 @@ public void blockFound(Block block) { } - blockChainDataListener.onBlock(block); - blockChainDataListener.onTransactions(block.getEra(), block.getHeader(), transactionEvents); + blockChainDataListener.onBlock(block.getEra(), block, transactionEvents); } private List getUtxosFromOutput(TransactionBody txBody) {