From 14376084a83a802670d05f404251b0948e0dc491 Mon Sep 17 00:00:00 2001 From: dkrsgood Date: Fri, 23 Feb 2024 21:52:43 +0800 Subject: [PATCH 1/8] Add node award --- .../java/io/xdag/config/AbstractConfig.java | 2 ++ .../java/io/xdag/config/spec/NodeSpec.java | 1 + src/main/java/io/xdag/core/XdagField.java | 11 +++---- .../io/xdag/pool/PoolAwardManagerImpl.java | 30 ++++++++++++------- src/main/resources/xdag-mainnet.conf | 3 +- src/test/java/io/xdag/consensus/TaskTest.java | 2 ++ src/test/java/io/xdag/core/XAmountTest.java | 6 ++++ src/test/java/io/xdag/wallet/WalletTest.java | 2 +- 8 files changed, 39 insertions(+), 18 deletions(-) diff --git a/src/main/java/io/xdag/config/AbstractConfig.java b/src/main/java/io/xdag/config/AbstractConfig.java index 7e7c48d6c..02c2d77d8 100644 --- a/src/main/java/io/xdag/config/AbstractConfig.java +++ b/src/main/java/io/xdag/config/AbstractConfig.java @@ -71,6 +71,7 @@ public class AbstractConfig implements Config, AdminSpec, NodeSpec, WalletSpec, // ========================= protected String fundAddress; protected double fundRation; + protected double nodeRation; // ========================= // Network // ========================= @@ -264,6 +265,7 @@ public void getSetting() { txPageSizeLimit = config.hasPath("node.transaction.history.pageSizeLimit") ? config.getInt("node.transaction.history.pageSizeLimit") : 500; fundAddress = config.hasPath("fund.address") ? config.getString("fund.address") : "4duPWMbYUgAifVYkKDCWxLvRRkSByf5gb"; fundRation = config.hasPath("fund.ration") ? config.getDouble("fund.ration") : 5; + nodeRation = config.hasPath("node.ration") ? config.getDouble("node.ration") : 5; List whiteIpList = config.getStringList("node.whiteIPs"); log.debug("{} IP access", whiteIpList.size()); for (String addr : whiteIpList) { diff --git a/src/main/java/io/xdag/config/spec/NodeSpec.java b/src/main/java/io/xdag/config/spec/NodeSpec.java index c0ae3101b..d0a28c172 100644 --- a/src/main/java/io/xdag/config/spec/NodeSpec.java +++ b/src/main/java/io/xdag/config/spec/NodeSpec.java @@ -103,5 +103,6 @@ public interface NodeSpec { //reject transaction address; String getRejectAddress(); boolean enableRefresh(); + double getNodeRation(); } diff --git a/src/main/java/io/xdag/core/XdagField.java b/src/main/java/io/xdag/core/XdagField.java index 19c3ba091..f3a016190 100644 --- a/src/main/java/io/xdag/core/XdagField.java +++ b/src/main/java/io/xdag/core/XdagField.java @@ -24,13 +24,14 @@ package io.xdag.core; -import java.nio.ByteOrder; -import java.util.HashMap; -import java.util.Map; import lombok.Getter; import lombok.Setter; import org.apache.tuweni.bytes.MutableBytes; +import java.nio.ByteOrder; +import java.util.HashMap; +import java.util.Map; + public class XdagField implements Cloneable { @Getter @@ -92,8 +93,8 @@ public enum FieldType { /*** *new tx type */ - XDAG_FIELD_INPUT(0x0C), - XDAG_FIELD_OUTPUT(0x0D), + XDAG_FIELD_INPUT(0x0C),//12 + XDAG_FIELD_OUTPUT(0x0D),//13 XDAG_FIELD_RESERVE5(0x0E), XDAG_FIELD_RESERVE6(0x0F); diff --git a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java index 394469e08..ade022268 100644 --- a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java +++ b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java @@ -37,6 +37,7 @@ public class PoolAwardManagerImpl implements PoolAwardManager, Runnable { private final Wallet wallet; private final String fundAddress; private final double fundRation; + private final double nodeRation; /** * The hash of the past sixteen blocks */ @@ -54,10 +55,11 @@ public class PoolAwardManagerImpl implements PoolAwardManager, Runnable { public PoolAwardManagerImpl(Kernel kernel) { this.kernel = kernel; this.config = kernel.getConfig(); + this.wallet = kernel.getWallet(); this.fundAddress = config.getFundSpec().getFundAddress(); this.fundRation = Math.max(0, Math.min(config.getFundSpec().getFundRation(), 100)); + this.nodeRation = Math.max(0, Math.min(config.getNodeSpec().getNodeRation(), 100)); this.blockchain = kernel.getBlockchain(); - this.wallet = kernel.getWallet(); init(); } @@ -127,7 +129,7 @@ public int payPools(long time) { log.info("Index of the block paid to the pool:{} ", paidBlockIndex); int keyPos; - // Obtain the block hash and corresponding nocne to be paid + // Obtain the block hash and corresponding share to be paid Bytes32 preHash = blockPreHashs.get(paidBlockIndex) == null ? null : blockPreHashs.get(paidBlockIndex); Bytes32 hash = blockHashs.get(paidBlockIndex) == null ? null : blockHashs.get(paidBlockIndex); Bytes32 share = minShares.get(paidBlockIndex) == null ? null : minShares.get(paidBlockIndex); @@ -147,7 +149,6 @@ public int payPools(long time) { log.debug("Can't find the block"); return -2; } - // if (compareTo(block.getNonce().slice(0, 20).toArray(), 0, 20, block.getCoinBase().getAddress().slice(8, 20).toArray(), 0, 20) == 0) { log.debug("This block is not produced by mining and belongs to the node"); @@ -159,15 +160,15 @@ public int payPools(long time) { keyPos = kernel.getBlockchain().getMemOurBlocks().get(hashlow); } if (keyPos < 0) { + log.debug("keyPos < 0,keyPos = {}", keyPos); return -4; } - XAmount payBalance = block.getInfo().getAmount(); - if (compareAmountTo(payBalance, XAmount.ZERO) <= 0) { + XAmount sendAmount = block.getInfo().getAmount(); + if (compareAmountTo(sendAmount, XAmount.ZERO) <= 0) { log.debug("no main block,can't pay"); return -5; } Bytes32 poolWalletAddress = BasicUtils.hexPubAddress2Hashlow(String.valueOf(block.getNonce().slice(0, 20))); - XAmount sendAmount = block.getInfo().getAmount(); log.debug("=========== At this time {} starts to distribute rewards to pools===========", time); TransactionInfoSender transactionInfoSender = new TransactionInfoSender(); transactionInfoSender.setPreHash(preHash); @@ -180,8 +181,17 @@ public void doPayments(Bytes32 hashLow, XAmount sendAmount, Bytes32 poolWalletAd TransactionInfoSender transactionInfoSender) { // Foundation rewards, default reward ratio is 5% XAmount fundAmount = sendAmount.multiply(div(fundRation, 100, 6)); + // Node rewards, default reward ratio is 5% + XAmount nodeAmount = sendAmount.multiply(div(nodeRation, 100, 6)); // Pool rewards - XAmount poolAmount = sendAmount.subtract(fundAmount); + XAmount poolAmount = sendAmount.subtract(fundAmount).subtract(nodeAmount); + if (fundRation + nodeRation >= 100 || poolAmount.lessThan(MIN_GAS)) { + log.error("Block reward distribution failed.The fundRation and nodeRation parameter settings are " + + "unreasonable.Your fundRation:{} ," + + "nodeRation:{}", fundRation, nodeRation); + return; + } + // Amount output: community and pool, the remaining part is node reward ArrayList
receipt = new ArrayList<>(2); if (sendAmount.compareTo(MIN_GAS.multiply(2)) >= 0) { receipt.add(new Address(pubAddress2Hash(fundAddress), XDAG_FIELD_OUTPUT, fundAmount, true)); @@ -233,10 +243,8 @@ public void transaction(Bytes32 hashLow, ArrayList
receipt, XAmount sen } else { log.error("Failed to add transaction history"); } - log.debug("The reward for block {} has been distributed to pool address {} ,send transaction " + - "information for pools to validate {}", hashLow, receipt.size() == 2 ? - WalletUtils.toBase58(receipt.get(0).getAddress().slice(8, 20).toArray()) : - " [Error: receipt error]", transactionInfoSender.toJsonString()); + log.debug("The reward for block {} has been distributed to pool address {}", hashLow, + WalletUtils.toBase58(receipt.get(1).getAddress().slice(8, 20).toArray())); } diff --git a/src/main/resources/xdag-mainnet.conf b/src/main/resources/xdag-mainnet.conf index dcb39aec2..b4a80b312 100644 --- a/src/main/resources/xdag-mainnet.conf +++ b/src/main/resources/xdag-mainnet.conf @@ -3,7 +3,7 @@ admin.telnet.ip = 127.0.0.1 admin.telnet.port = 6001 admin.telnet.password = 123 -# Pool websocket Config (Node <--> pools) +# Pool websocket Config (Node <--> Pools) pool.whiteIPs = ["0.0.0.0"] pool.ws.port = 7001 @@ -15,6 +15,7 @@ node.maxInboundConnectionsPerIp = 8 node.whiteIPs = ["127.0.0.1:8002"] node.generate.block.enable = true node.reject.transaction.address = 111111111111111111117K4nzc +node.ration = 5 # Fund config fund.address = "4duPWMbYUgAifVYkKDCWxLvRRkSByf5gb" diff --git a/src/test/java/io/xdag/consensus/TaskTest.java b/src/test/java/io/xdag/consensus/TaskTest.java index ff80ed9f8..6078faf4c 100644 --- a/src/test/java/io/xdag/consensus/TaskTest.java +++ b/src/test/java/io/xdag/consensus/TaskTest.java @@ -42,6 +42,7 @@ import org.apache.tuweni.bytes.Bytes32; import org.apache.tuweni.bytes.MutableBytes; import org.hyperledger.besu.crypto.KeyPair; +import org.jline.utils.Log; import org.json.JSONObject; import org.junit.After; import org.junit.Before; @@ -174,6 +175,7 @@ public void testSend2PoolsTxInfoConvertToJsonFormat() { transactionInfoSender.setFee(MIN_GAS.toDecimal(9, XDAG).toPlainString()); XAmount amount = XAmount.of(64, XDAG); XAmount fundAmount = amount.multiply(div(fundRation, 100, 6)); + Log.info(fundAmount.toDecimal(9,XDAG).toPlainString()); transactionInfoSender.setAmount(amount.subtract(MIN_GAS).subtract(fundAmount).toDecimal(9, XDAG).toPlainString()); transactionInfoSender.setDonate(fundAmount.toDecimal(9, XDAG).toPlainString()); diff --git a/src/test/java/io/xdag/core/XAmountTest.java b/src/test/java/io/xdag/core/XAmountTest.java index d8e7ef6de..5480e662b 100644 --- a/src/test/java/io/xdag/core/XAmountTest.java +++ b/src/test/java/io/xdag/core/XAmountTest.java @@ -28,6 +28,7 @@ import java.math.BigDecimal; +import static io.xdag.config.Constants.MIN_GAS; import static io.xdag.core.XAmount.ZERO; import static io.xdag.core.XUnit.*; import static org.junit.Assert.*; @@ -105,6 +106,11 @@ public void testGtLtEtc() { assertTrue(XAmount.of(999, XDAG).greaterThanOrEqual(XAmount.of(999, MILLI_XDAG))); assertFalse(XAmount.of(999, XDAG).lessThan(XAmount.of(999, MILLI_XDAG))); assertFalse(XAmount.of(999, XDAG).lessThanOrEqual(XAmount.of(999, MILLI_XDAG))); + XAmount amount1 = XAmount.of(64, XDAG); + XAmount amount2 = XAmount.of(63, XDAG); + assertFalse(amount1.lessThanOrEqual(amount2)); + XAmount amount3 = XAmount.of(101, MILLI_XDAG); + assertFalse(amount3.lessThanOrEqual(MIN_GAS)); } @Test diff --git a/src/test/java/io/xdag/wallet/WalletTest.java b/src/test/java/io/xdag/wallet/WalletTest.java index 100193140..70404ca15 100644 --- a/src/test/java/io/xdag/wallet/WalletTest.java +++ b/src/test/java/io/xdag/wallet/WalletTest.java @@ -208,7 +208,7 @@ public void testGetWalletAddress() { Log.info(wallet.getDefKey()); Log.info(keyPair2Hash(wallet.getDefKey())); Log.info(hash2PubAddress(keyPair2Hash(wallet.getDefKey()))); - WalletUtils.checkAddress(hash2PubAddress(keyPair2Hash(wallet.getDefKey()))); + assertTrue(WalletUtils.checkAddress(hash2PubAddress(keyPair2Hash(wallet.getDefKey())))); } @After From d370dcd997b4c2be6a2aa639aa19f75b8cce0b70 Mon Sep 17 00:00:00 2001 From: dkrsgood Date: Fri, 23 Feb 2024 21:57:45 +0800 Subject: [PATCH 2/8] Add node award --- src/main/java/io/xdag/cli/Commands.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/io/xdag/cli/Commands.java b/src/main/java/io/xdag/cli/Commands.java index 4f51ca278..8a2398a76 100644 --- a/src/main/java/io/xdag/cli/Commands.java +++ b/src/main/java/io/xdag/cli/Commands.java @@ -679,7 +679,7 @@ public String xferToNew() { Bytes32 accountHash = keyPair2Hash(kernel.getWallet().getDefKey()); to.set(8, accountHash.slice(8, 20)); - String remark = "old balance to new address"; + String remark = "block balance to new address"; // 转账输入 Map ourBlocks = Maps.newHashMap(); From bb398d5d947d9833dae021b94f867c138b7c2c09 Mon Sep 17 00:00:00 2001 From: dkrsgood Date: Mon, 26 Feb 2024 10:14:14 +0800 Subject: [PATCH 3/8] Modify the mode of node rewards --- .../io/xdag/pool/PoolAwardManagerImpl.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java index ade022268..4f39c15e1 100644 --- a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java +++ b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java @@ -30,12 +30,13 @@ @Slf4j public class PoolAwardManagerImpl implements PoolAwardManager, Runnable { - private static final String TX_REMARK = "Block Reward Distribution"; + private static final String TX_REMARK = ""; private final Kernel kernel; protected Config config; private final Blockchain blockchain; private final Wallet wallet; private final String fundAddress; + private final Bytes32 nodeAddress; private final double fundRation; private final double nodeRation; /** @@ -57,6 +58,7 @@ public PoolAwardManagerImpl(Kernel kernel) { this.config = kernel.getConfig(); this.wallet = kernel.getWallet(); this.fundAddress = config.getFundSpec().getFundAddress(); + this.nodeAddress = keyPair2Hash(wallet.getDefKey()); this.fundRation = Math.max(0, Math.min(config.getFundSpec().getFundRation(), 100)); this.nodeRation = Math.max(0, Math.min(config.getNodeSpec().getNodeRation(), 100)); this.blockchain = kernel.getBlockchain(); @@ -185,16 +187,18 @@ public void doPayments(Bytes32 hashLow, XAmount sendAmount, Bytes32 poolWalletAd XAmount nodeAmount = sendAmount.multiply(div(nodeRation, 100, 6)); // Pool rewards XAmount poolAmount = sendAmount.subtract(fundAmount).subtract(nodeAmount); - if (fundRation + nodeRation >= 100 || poolAmount.lessThan(MIN_GAS)) { + if (fundRation + nodeRation >= 100 || fundAmount.lessThan(MIN_GAS) || nodeAmount.lessThan(MIN_GAS) + || poolAmount.lessThan(MIN_GAS)) { log.error("Block reward distribution failed.The fundRation and nodeRation parameter settings are " + "unreasonable.Your fundRation:{} ," + "nodeRation:{}", fundRation, nodeRation); return; } - // Amount output: community and pool, the remaining part is node reward - ArrayList
receipt = new ArrayList<>(2); - if (sendAmount.compareTo(MIN_GAS.multiply(2)) >= 0) { + // Amount output: community, pool and node + ArrayList
receipt = new ArrayList<>(3); + if (sendAmount.compareTo(MIN_GAS.multiply(3)) >= 0) { receipt.add(new Address(pubAddress2Hash(fundAddress), XDAG_FIELD_OUTPUT, fundAmount, true)); + receipt.add(new Address(nodeAddress, XDAG_FIELD_OUTPUT, nodeAmount, true)); receipt.add(new Address(poolWalletAddress, XDAG_FIELD_OUTPUT, poolAmount, true)); transactionInfoSender.setAmount(poolAmount.subtract(MIN_GAS).toDecimal(9, XUnit.XDAG).toPlainString()); @@ -204,8 +208,8 @@ public void doPayments(Bytes32 hashLow, XAmount sendAmount, Bytes32 poolWalletAd transaction(hashLow, receipt, sendAmount, keyPos, transactionInfoSender); } else { log.debug("The balance of block {} is insufficient and rewards will not be distributed. Maybe this block " + - "has been rollback", - hashLow.toHexString()); + "has been rollback. Block balance:{}", + hashLow.toHexString(), sendAmount.toDecimal(9, XUnit.XDAG).toPlainString()); } receipt.clear(); } From 6fcbc084a4e44605a4a1691c5b906e761410bca4 Mon Sep 17 00:00:00 2001 From: dkrsgood Date: Mon, 26 Feb 2024 14:19:08 +0800 Subject: [PATCH 4/8] fix some bug about node rewards --- .../io/xdag/pool/PoolAwardManagerImpl.java | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java index 4f39c15e1..a17083534 100644 --- a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java +++ b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java @@ -36,7 +36,6 @@ public class PoolAwardManagerImpl implements PoolAwardManager, Runnable { private final Blockchain blockchain; private final Wallet wallet; private final String fundAddress; - private final Bytes32 nodeAddress; private final double fundRation; private final double nodeRation; /** @@ -58,7 +57,6 @@ public PoolAwardManagerImpl(Kernel kernel) { this.config = kernel.getConfig(); this.wallet = kernel.getWallet(); this.fundAddress = config.getFundSpec().getFundAddress(); - this.nodeAddress = keyPair2Hash(wallet.getDefKey()); this.fundRation = Math.max(0, Math.min(config.getFundSpec().getFundRation(), 100)); this.nodeRation = Math.max(0, Math.min(config.getNodeSpec().getNodeRation(), 100)); this.blockchain = kernel.getBlockchain(); @@ -165,8 +163,8 @@ public int payPools(long time) { log.debug("keyPos < 0,keyPos = {}", keyPos); return -4; } - XAmount sendAmount = block.getInfo().getAmount(); - if (compareAmountTo(sendAmount, XAmount.ZERO) <= 0) { + XAmount allAmount = block.getInfo().getAmount(); + if (compareAmountTo(allAmount, XAmount.ZERO) <= 0) { log.debug("no main block,can't pay"); return -5; } @@ -175,30 +173,30 @@ public int payPools(long time) { TransactionInfoSender transactionInfoSender = new TransactionInfoSender(); transactionInfoSender.setPreHash(preHash); transactionInfoSender.setShare(share); - doPayments(hashlow, sendAmount, poolWalletAddress, keyPos, transactionInfoSender); + doPayments(hashlow, allAmount, poolWalletAddress, keyPos, transactionInfoSender); return 0; } - public void doPayments(Bytes32 hashLow, XAmount sendAmount, Bytes32 poolWalletAddress, int keyPos, + public void doPayments(Bytes32 hashLow, XAmount allAmount, Bytes32 poolWalletAddress, int keyPos, TransactionInfoSender transactionInfoSender) { // Foundation rewards, default reward ratio is 5% - XAmount fundAmount = sendAmount.multiply(div(fundRation, 100, 6)); + XAmount fundAmount = allAmount.multiply(div(fundRation, 100, 6)); // Node rewards, default reward ratio is 5% - XAmount nodeAmount = sendAmount.multiply(div(nodeRation, 100, 6)); + XAmount nodeAmount = allAmount.multiply(div(nodeRation, 100, 6)); // Pool rewards - XAmount poolAmount = sendAmount.subtract(fundAmount).subtract(nodeAmount); - if (fundRation + nodeRation >= 100 || fundAmount.lessThan(MIN_GAS) || nodeAmount.lessThan(MIN_GAS) - || poolAmount.lessThan(MIN_GAS)) { + XAmount poolAmount = allAmount.subtract(fundAmount).subtract(nodeAmount); + // sendAmount = Foundation rewards + Pool rewards + XAmount sendAmount = allAmount.subtract(nodeAmount); + if (fundRation + nodeRation >= 100 || fundAmount.lessThan(MIN_GAS) || poolAmount.lessThan(MIN_GAS)) { log.error("Block reward distribution failed.The fundRation and nodeRation parameter settings are " + "unreasonable.Your fundRation:{} ," + "nodeRation:{}", fundRation, nodeRation); return; } // Amount output: community, pool and node - ArrayList
receipt = new ArrayList<>(3); - if (sendAmount.compareTo(MIN_GAS.multiply(3)) >= 0) { + ArrayList
receipt = new ArrayList<>(2); + if (sendAmount.compareTo(MIN_GAS.multiply(2)) >= 0) { receipt.add(new Address(pubAddress2Hash(fundAddress), XDAG_FIELD_OUTPUT, fundAmount, true)); - receipt.add(new Address(nodeAddress, XDAG_FIELD_OUTPUT, nodeAmount, true)); receipt.add(new Address(poolWalletAddress, XDAG_FIELD_OUTPUT, poolAmount, true)); transactionInfoSender.setAmount(poolAmount.subtract(MIN_GAS).toDecimal(9, XUnit.XDAG).toPlainString()); @@ -208,7 +206,7 @@ public void doPayments(Bytes32 hashLow, XAmount sendAmount, Bytes32 poolWalletAd transaction(hashLow, receipt, sendAmount, keyPos, transactionInfoSender); } else { log.debug("The balance of block {} is insufficient and rewards will not be distributed. Maybe this block " + - "has been rollback. Block balance:{}", + "has been rollback. send balance:{}", hashLow.toHexString(), sendAmount.toDecimal(9, XUnit.XDAG).toPlainString()); } receipt.clear(); @@ -216,7 +214,7 @@ public void doPayments(Bytes32 hashLow, XAmount sendAmount, Bytes32 poolWalletAd public void transaction(Bytes32 hashLow, ArrayList
receipt, XAmount sendAmount, int keypos, TransactionInfoSender transactionInfoSender) { - log.debug("All balance in this block: {}", sendAmount); + log.debug("Total balance pending transfer: {}", sendAmount); log.debug("unlock keypos =[{}]", keypos); Map inputMap = new HashMap<>(); Address input = new Address(hashLow, XDAG_FIELD_IN, sendAmount, false); From d7d3fd9b658697ca7260714de1b82aa500231086 Mon Sep 17 00:00:00 2001 From: dkrsgood Date: Mon, 4 Mar 2024 15:43:59 +0800 Subject: [PATCH 5/8] node rewards are distributed regularly --- src/main/java/io/xdag/cli/Commands.java | 57 +++++++++++++------ .../io/xdag/pool/PoolAwardManagerImpl.java | 17 +++++- 2 files changed, 53 insertions(+), 21 deletions(-) diff --git a/src/main/java/io/xdag/cli/Commands.java b/src/main/java/io/xdag/cli/Commands.java index 8a2398a76..87cc80ea4 100644 --- a/src/main/java/io/xdag/cli/Commands.java +++ b/src/main/java/io/xdag/cli/Commands.java @@ -301,13 +301,12 @@ private List createTransactionBlock(Map ourKeys, if (keys.size() != 0) { res.add(createTransaction(to, amount, keys, remark)); } - return res; } private BlockWrapper createTransaction(Bytes32 to, XAmount amount, Map keys, String remark) { List
tos = Lists.newArrayList(new Address(to, XDAG_FIELD_OUTPUT, amount, true)); - Block block = kernel.getBlockchain().createNewBlock(new HashMap<>(keys), tos, false, remark, XAmount.of(100,XUnit.MILLI_XDAG)); + Block block = kernel.getBlockchain().createNewBlock(new HashMap<>(keys), tos, false, remark, XAmount.of(100, XUnit.MILLI_XDAG)); if (block == null) { return null; @@ -449,11 +448,11 @@ public String printBlockInfo(Block block, boolean raw) { outputs.append(String.format(" output: %s %s%n", output.getIsAddress() ? toBase58(hash2byte(output.getAddress())) : hash2Address(output.getAddress()), getStateByFlags(block.getInfo().getFlags()).equals(MAIN.getDesc()) ? output.getAmount().toDecimal(9, XUnit.XDAG).toPlainString() : - block.getInputs().isEmpty() ? XAmount.ZERO.toDecimal(9,XUnit.XDAG).toPlainString() : - output.getAmount().subtract(MIN_GAS).toDecimal(9, XUnit.XDAG).toPlainString() + block.getInputs().isEmpty() ? XAmount.ZERO.toDecimal(9, XUnit.XDAG).toPlainString() : + output.getAmount().subtract(MIN_GAS).toDecimal(9, XUnit.XDAG).toPlainString() )); - //three type of block, 1、main block :getStateByFlags(block.getInfo().getFlags()).equals(MAIN.getDesc()) - //2、link block:block.getInputs().isEmpty() 3、else transaction block + // three type of block, 1、main block :getStateByFlags(block.getInfo().getFlags()).equals(MAIN.getDesc()) + // 2、link block:block.getInputs().isEmpty() 3、else transaction block } } } @@ -466,13 +465,13 @@ public String printBlockInfo(Block block, boolean raw) { StringBuilder tx = new StringBuilder(); if (getStateByFlags(block.getInfo().getFlags()).equals(MAIN.getDesc()) && block.getInfo().getHeight() > kernel.getConfig().getSnapshotSpec().getSnapshotHeight()) { tx.append(String.format(" earn: %s %s %s%n", hash2Address(block.getHashLow()), - kernel.getBlockchain().getReward(block.getInfo().getHeight()).toDecimal(9, XUnit.XDAG).toPlainString(), - FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSS") - .format(XdagTime.xdagTimestampToMs(block.getTimestamp())))) - .append(String.format("fee earn: %s %s %s%n", hash2Address(block.getHashLow()), - kernel.getBlockStore().getBlockInfoByHash(block.getHashLow()).getFee().toDecimal(9, XUnit.XDAG).toPlainString(), - FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSS") - .format(XdagTime.xdagTimestampToMs(block.getTimestamp())))); + kernel.getBlockchain().getReward(block.getInfo().getHeight()).toDecimal(9, XUnit.XDAG).toPlainString(), + FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSS") + .format(XdagTime.xdagTimestampToMs(block.getTimestamp())))) + .append(String.format("fee earn: %s %s %s%n", hash2Address(block.getHashLow()), + kernel.getBlockStore().getBlockInfoByHash(block.getHashLow()).getFee().toDecimal(9, XUnit.XDAG).toPlainString(), + FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSS") + .format(XdagTime.xdagTimestampToMs(block.getTimestamp())))); } for (TxHistory txHistory : kernel.getBlockchain().getBlockTxHistoryByAddress(block.getHashLow(), 1)) { Address address = txHistory.getAddress(); @@ -500,8 +499,8 @@ public String printBlockInfo(Block block, boolean raw) { } // TODO need add block as transaction - //three type of block, main block :getStateByFlags(block.getInfo().getFlags()).equals(MAIN.getDesc()) - //link block:block.getInputs().isEmpty() else transaction block + // three type of block, main block :getStateByFlags(block.getInfo().getFlags()).equals(MAIN.getDesc()) + // link block:block.getInputs().isEmpty() else transaction block return String.format(heightFormat, block.getInfo().getHeight()) + String.format(otherFormat, FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss.SSS").format(time), Long.toHexString(block.getTimestamp()), @@ -514,8 +513,8 @@ public String printBlockInfo(Block block, boolean raw) { block.getInfo().getRef() == null ? "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" : hash2Address(Bytes32.wrap(block.getInfo().getRef())), block.getInfo().getRef() == null ? XAmount.ZERO.toDecimal(9, XUnit.XDAG).toPlainString() : (getStateByFlags(block.getInfo().getFlags()).equals(MAIN.getDesc()) ? kernel.getBlockStore().getBlockInfoByHash(block.getHashLow()).getFee().toDecimal(9, XUnit.XDAG).toPlainString() : - (block.getInputs().isEmpty() ? XAmount.ZERO.toDecimal(9,XUnit.XDAG).toPlainString() : - MIN_GAS.multiply(block.getOutputs().size()).toDecimal(9,XUnit.XDAG).toPlainString())) + (block.getInputs().isEmpty() ? XAmount.ZERO.toDecimal(9, XUnit.XDAG).toPlainString() : + MIN_GAS.multiply(block.getOutputs().size()).toDecimal(9, XUnit.XDAG).toPlainString())) ) + "\n" + (inputs == null ? "" : inputs.toString()) + (outputs == null ? "" : outputs.toString()) @@ -580,7 +579,7 @@ public String listConnect() { return stringBuilder.toString(); } - public String pool(){ + public String pool() { return ChannelSupervise.showChannel(); } @@ -711,4 +710,26 @@ public String xferToNew() { } return str.append("}, it will take several minutes to complete the transaction.").toString(); } + + // Distribute block rewards to node + public StringBuilder xferToNode(Map paymentsToNodesMap) { + StringBuilder str = new StringBuilder("Tx hash paid to the node :{"); + MutableBytes32 to = MutableBytes32.create(); + Bytes32 accountHash = keyPair2Hash(kernel.getWallet().getDefKey()); + to.set(8, accountHash.slice(8, 20)); + String remark = "Pay to " + kernel.getConfig().getNodeSpec().getNodeTag(); + // Generate tx block to reward node + List txs = createTransactionBlock(paymentsToNodesMap, to, remark); + for (BlockWrapper blockWrapper : txs) { + ImportResult result = kernel.getSyncMgr().validateAndAddNewBlock(blockWrapper); + if (result == ImportResult.IMPORTED_BEST || result == ImportResult.IMPORTED_NOT_BEST) { + kernel.getChannelMgr().sendNewBlock(blockWrapper); + str.append(BasicUtils.hash2Address(blockWrapper.getBlock().getHashLow())); + } else { + return new StringBuilder("This transaction block is invalid. Tx hash:") + .append(BasicUtils.hash2Address(blockWrapper.getBlock().getHashLow())); + } + } + return str.append("}"); + } } diff --git a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java index a17083534..1a07726bc 100644 --- a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java +++ b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java @@ -2,6 +2,7 @@ import io.xdag.Kernel; import io.xdag.Wallet; +import io.xdag.cli.Commands; import io.xdag.config.Config; import io.xdag.core.*; import io.xdag.net.websocket.ChannelSupervise; @@ -38,12 +39,14 @@ public class PoolAwardManagerImpl implements PoolAwardManager, Runnable { private final String fundAddress; private final double fundRation; private final double nodeRation; + private final Commands commands; /** * The hash of the past sixteen blocks */ protected List blockPreHashs = new CopyOnWriteArrayList<>(new ArrayList<>(16)); protected List blockHashs = new CopyOnWriteArrayList<>(new ArrayList<>(16)); protected List minShares = new CopyOnWriteArrayList<>(new ArrayList<>(16)); + private final Map paymentsToNodesMap = new HashMap<>(10); private static final BlockingQueue awardBlockBlockingQueue = new LinkedBlockingQueue<>(); private final ExecutorService workExecutor = Executors.newSingleThreadExecutor(new BasicThreadFactory.Builder() @@ -60,6 +63,7 @@ public PoolAwardManagerImpl(Kernel kernel) { this.fundRation = Math.max(0, Math.min(config.getFundSpec().getFundRation(), 100)); this.nodeRation = Math.max(0, Math.min(config.getNodeSpec().getNodeRation(), 100)); this.blockchain = kernel.getBlockchain(); + this.commands = new Commands(kernel); init(); } @@ -179,6 +183,11 @@ public int payPools(long time) { public void doPayments(Bytes32 hashLow, XAmount allAmount, Bytes32 poolWalletAddress, int keyPos, TransactionInfoSender transactionInfoSender) { + if (paymentsToNodesMap.size() == 10) { + StringBuilder txHash = commands.xferToNode(paymentsToNodesMap); + log.info(String.valueOf(txHash)); + paymentsToNodesMap.clear(); + } // Foundation rewards, default reward ratio is 5% XAmount fundAmount = allAmount.multiply(div(fundRation, 100, 6)); // Node rewards, default reward ratio is 5% @@ -204,6 +213,8 @@ public void doPayments(Bytes32 hashLow, XAmount allAmount, Bytes32 poolWalletAdd transactionInfoSender.setDonate(fundAmount.toDecimal(9, XUnit.XDAG).toPlainString()); log.debug("Start payment..."); transaction(hashLow, receipt, sendAmount, keyPos, transactionInfoSender); + paymentsToNodesMap.put(new Address(hashLow, XDAG_FIELD_IN, nodeAmount, false), + wallet.getAccount(keyPos)); } else { log.debug("The balance of block {} is insufficient and rewards will not be distributed. Maybe this block " + "has been rollback. send balance:{}", @@ -212,13 +223,13 @@ public void doPayments(Bytes32 hashLow, XAmount allAmount, Bytes32 poolWalletAdd receipt.clear(); } - public void transaction(Bytes32 hashLow, ArrayList
receipt, XAmount sendAmount, int keypos, + public void transaction(Bytes32 hashLow, ArrayList
receipt, XAmount sendAmount, int keyPos, TransactionInfoSender transactionInfoSender) { log.debug("Total balance pending transfer: {}", sendAmount); - log.debug("unlock keypos =[{}]", keypos); + log.debug("unlock keypos =[{}]", keyPos); Map inputMap = new HashMap<>(); Address input = new Address(hashLow, XDAG_FIELD_IN, sendAmount, false); - KeyPair inputKey = wallet.getAccount(keypos); + KeyPair inputKey = wallet.getAccount(keyPos); inputMap.put(input, inputKey); Block block = blockchain.createNewBlock(inputMap, receipt, false, TX_REMARK, MIN_GAS); if (inputKey.equals(wallet.getDefKey())) { From 87f974c24e0e203bf8152285f943d2bea8d4e9f5 Mon Sep 17 00:00:00 2001 From: dkrsgood Date: Tue, 5 Mar 2024 12:07:28 +0800 Subject: [PATCH 6/8] Version rollback --- src/main/java/io/xdag/cli/Commands.java | 40 +++++++++---------- .../io/xdag/pool/PoolAwardManagerImpl.java | 21 +++++----- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/src/main/java/io/xdag/cli/Commands.java b/src/main/java/io/xdag/cli/Commands.java index 87cc80ea4..32d74e56e 100644 --- a/src/main/java/io/xdag/cli/Commands.java +++ b/src/main/java/io/xdag/cli/Commands.java @@ -712,24 +712,24 @@ public String xferToNew() { } // Distribute block rewards to node - public StringBuilder xferToNode(Map paymentsToNodesMap) { - StringBuilder str = new StringBuilder("Tx hash paid to the node :{"); - MutableBytes32 to = MutableBytes32.create(); - Bytes32 accountHash = keyPair2Hash(kernel.getWallet().getDefKey()); - to.set(8, accountHash.slice(8, 20)); - String remark = "Pay to " + kernel.getConfig().getNodeSpec().getNodeTag(); - // Generate tx block to reward node - List txs = createTransactionBlock(paymentsToNodesMap, to, remark); - for (BlockWrapper blockWrapper : txs) { - ImportResult result = kernel.getSyncMgr().validateAndAddNewBlock(blockWrapper); - if (result == ImportResult.IMPORTED_BEST || result == ImportResult.IMPORTED_NOT_BEST) { - kernel.getChannelMgr().sendNewBlock(blockWrapper); - str.append(BasicUtils.hash2Address(blockWrapper.getBlock().getHashLow())); - } else { - return new StringBuilder("This transaction block is invalid. Tx hash:") - .append(BasicUtils.hash2Address(blockWrapper.getBlock().getHashLow())); - } - } - return str.append("}"); - } + // public StringBuilder xferToNode(Map paymentsToNodesMap) { + // StringBuilder str = new StringBuilder("Tx hash paid to the node :{"); + // MutableBytes32 to = MutableBytes32.create(); + // Bytes32 accountHash = keyPair2Hash(kernel.getWallet().getDefKey()); + // to.set(8, accountHash.slice(8, 20)); + // String remark = "Pay to " + kernel.getConfig().getNodeSpec().getNodeTag(); + // // Generate tx block to reward node + // List txs = createTransactionBlock(paymentsToNodesMap, to, remark); + // for (BlockWrapper blockWrapper : txs) { + // ImportResult result = kernel.getSyncMgr().validateAndAddNewBlock(blockWrapper); + // if (result == ImportResult.IMPORTED_BEST || result == ImportResult.IMPORTED_NOT_BEST) { + // kernel.getChannelMgr().sendNewBlock(blockWrapper); + // str.append(BasicUtils.hash2Address(blockWrapper.getBlock().getHashLow())); + // } else { + // return new StringBuilder("This transaction block is invalid. Tx hash:") + // .append(BasicUtils.hash2Address(blockWrapper.getBlock().getHashLow())); + // } + // } + // return str.append("}"); + // } } diff --git a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java index 1a07726bc..7c4a933ec 100644 --- a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java +++ b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java @@ -2,7 +2,6 @@ import io.xdag.Kernel; import io.xdag.Wallet; -import io.xdag.cli.Commands; import io.xdag.config.Config; import io.xdag.core.*; import io.xdag.net.websocket.ChannelSupervise; @@ -39,14 +38,14 @@ public class PoolAwardManagerImpl implements PoolAwardManager, Runnable { private final String fundAddress; private final double fundRation; private final double nodeRation; - private final Commands commands; + // private final Commands commands; /** * The hash of the past sixteen blocks */ protected List blockPreHashs = new CopyOnWriteArrayList<>(new ArrayList<>(16)); protected List blockHashs = new CopyOnWriteArrayList<>(new ArrayList<>(16)); protected List minShares = new CopyOnWriteArrayList<>(new ArrayList<>(16)); - private final Map paymentsToNodesMap = new HashMap<>(10); + // private final Map paymentsToNodesMap = new HashMap<>(10); private static final BlockingQueue awardBlockBlockingQueue = new LinkedBlockingQueue<>(); private final ExecutorService workExecutor = Executors.newSingleThreadExecutor(new BasicThreadFactory.Builder() @@ -63,7 +62,7 @@ public PoolAwardManagerImpl(Kernel kernel) { this.fundRation = Math.max(0, Math.min(config.getFundSpec().getFundRation(), 100)); this.nodeRation = Math.max(0, Math.min(config.getNodeSpec().getNodeRation(), 100)); this.blockchain = kernel.getBlockchain(); - this.commands = new Commands(kernel); + // this.commands = new Commands(kernel); init(); } @@ -183,11 +182,11 @@ public int payPools(long time) { public void doPayments(Bytes32 hashLow, XAmount allAmount, Bytes32 poolWalletAddress, int keyPos, TransactionInfoSender transactionInfoSender) { - if (paymentsToNodesMap.size() == 10) { - StringBuilder txHash = commands.xferToNode(paymentsToNodesMap); - log.info(String.valueOf(txHash)); - paymentsToNodesMap.clear(); - } + // if (paymentsToNodesMap.size() == 10) { + // StringBuilder txHash = commands.xferToNode(paymentsToNodesMap); + // log.info(String.valueOf(txHash)); + // paymentsToNodesMap.clear(); + // } // Foundation rewards, default reward ratio is 5% XAmount fundAmount = allAmount.multiply(div(fundRation, 100, 6)); // Node rewards, default reward ratio is 5% @@ -213,8 +212,8 @@ public void doPayments(Bytes32 hashLow, XAmount allAmount, Bytes32 poolWalletAdd transactionInfoSender.setDonate(fundAmount.toDecimal(9, XUnit.XDAG).toPlainString()); log.debug("Start payment..."); transaction(hashLow, receipt, sendAmount, keyPos, transactionInfoSender); - paymentsToNodesMap.put(new Address(hashLow, XDAG_FIELD_IN, nodeAmount, false), - wallet.getAccount(keyPos)); + // paymentsToNodesMap.put(new Address(hashLow, XDAG_FIELD_IN, nodeAmount, false), + // wallet.getAccount(keyPos)); } else { log.debug("The balance of block {} is insufficient and rewards will not be distributed. Maybe this block " + "has been rollback. send balance:{}", From 8ea522fac088bbc1da0f46e23bca46d067c75c92 Mon Sep 17 00:00:00 2001 From: dkrsgood Date: Tue, 5 Mar 2024 12:31:58 +0800 Subject: [PATCH 7/8] version advance --- src/main/java/io/xdag/cli/Commands.java | 40 +++++++++---------- .../io/xdag/pool/PoolAwardManagerImpl.java | 21 +++++----- 2 files changed, 31 insertions(+), 30 deletions(-) diff --git a/src/main/java/io/xdag/cli/Commands.java b/src/main/java/io/xdag/cli/Commands.java index 32d74e56e..87cc80ea4 100644 --- a/src/main/java/io/xdag/cli/Commands.java +++ b/src/main/java/io/xdag/cli/Commands.java @@ -712,24 +712,24 @@ public String xferToNew() { } // Distribute block rewards to node - // public StringBuilder xferToNode(Map paymentsToNodesMap) { - // StringBuilder str = new StringBuilder("Tx hash paid to the node :{"); - // MutableBytes32 to = MutableBytes32.create(); - // Bytes32 accountHash = keyPair2Hash(kernel.getWallet().getDefKey()); - // to.set(8, accountHash.slice(8, 20)); - // String remark = "Pay to " + kernel.getConfig().getNodeSpec().getNodeTag(); - // // Generate tx block to reward node - // List txs = createTransactionBlock(paymentsToNodesMap, to, remark); - // for (BlockWrapper blockWrapper : txs) { - // ImportResult result = kernel.getSyncMgr().validateAndAddNewBlock(blockWrapper); - // if (result == ImportResult.IMPORTED_BEST || result == ImportResult.IMPORTED_NOT_BEST) { - // kernel.getChannelMgr().sendNewBlock(blockWrapper); - // str.append(BasicUtils.hash2Address(blockWrapper.getBlock().getHashLow())); - // } else { - // return new StringBuilder("This transaction block is invalid. Tx hash:") - // .append(BasicUtils.hash2Address(blockWrapper.getBlock().getHashLow())); - // } - // } - // return str.append("}"); - // } + public StringBuilder xferToNode(Map paymentsToNodesMap) { + StringBuilder str = new StringBuilder("Tx hash paid to the node :{"); + MutableBytes32 to = MutableBytes32.create(); + Bytes32 accountHash = keyPair2Hash(kernel.getWallet().getDefKey()); + to.set(8, accountHash.slice(8, 20)); + String remark = "Pay to " + kernel.getConfig().getNodeSpec().getNodeTag(); + // Generate tx block to reward node + List txs = createTransactionBlock(paymentsToNodesMap, to, remark); + for (BlockWrapper blockWrapper : txs) { + ImportResult result = kernel.getSyncMgr().validateAndAddNewBlock(blockWrapper); + if (result == ImportResult.IMPORTED_BEST || result == ImportResult.IMPORTED_NOT_BEST) { + kernel.getChannelMgr().sendNewBlock(blockWrapper); + str.append(BasicUtils.hash2Address(blockWrapper.getBlock().getHashLow())); + } else { + return new StringBuilder("This transaction block is invalid. Tx hash:") + .append(BasicUtils.hash2Address(blockWrapper.getBlock().getHashLow())); + } + } + return str.append("}"); + } } diff --git a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java index 7c4a933ec..1a07726bc 100644 --- a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java +++ b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java @@ -2,6 +2,7 @@ import io.xdag.Kernel; import io.xdag.Wallet; +import io.xdag.cli.Commands; import io.xdag.config.Config; import io.xdag.core.*; import io.xdag.net.websocket.ChannelSupervise; @@ -38,14 +39,14 @@ public class PoolAwardManagerImpl implements PoolAwardManager, Runnable { private final String fundAddress; private final double fundRation; private final double nodeRation; - // private final Commands commands; + private final Commands commands; /** * The hash of the past sixteen blocks */ protected List blockPreHashs = new CopyOnWriteArrayList<>(new ArrayList<>(16)); protected List blockHashs = new CopyOnWriteArrayList<>(new ArrayList<>(16)); protected List minShares = new CopyOnWriteArrayList<>(new ArrayList<>(16)); - // private final Map paymentsToNodesMap = new HashMap<>(10); + private final Map paymentsToNodesMap = new HashMap<>(10); private static final BlockingQueue awardBlockBlockingQueue = new LinkedBlockingQueue<>(); private final ExecutorService workExecutor = Executors.newSingleThreadExecutor(new BasicThreadFactory.Builder() @@ -62,7 +63,7 @@ public PoolAwardManagerImpl(Kernel kernel) { this.fundRation = Math.max(0, Math.min(config.getFundSpec().getFundRation(), 100)); this.nodeRation = Math.max(0, Math.min(config.getNodeSpec().getNodeRation(), 100)); this.blockchain = kernel.getBlockchain(); - // this.commands = new Commands(kernel); + this.commands = new Commands(kernel); init(); } @@ -182,11 +183,11 @@ public int payPools(long time) { public void doPayments(Bytes32 hashLow, XAmount allAmount, Bytes32 poolWalletAddress, int keyPos, TransactionInfoSender transactionInfoSender) { - // if (paymentsToNodesMap.size() == 10) { - // StringBuilder txHash = commands.xferToNode(paymentsToNodesMap); - // log.info(String.valueOf(txHash)); - // paymentsToNodesMap.clear(); - // } + if (paymentsToNodesMap.size() == 10) { + StringBuilder txHash = commands.xferToNode(paymentsToNodesMap); + log.info(String.valueOf(txHash)); + paymentsToNodesMap.clear(); + } // Foundation rewards, default reward ratio is 5% XAmount fundAmount = allAmount.multiply(div(fundRation, 100, 6)); // Node rewards, default reward ratio is 5% @@ -212,8 +213,8 @@ public void doPayments(Bytes32 hashLow, XAmount allAmount, Bytes32 poolWalletAdd transactionInfoSender.setDonate(fundAmount.toDecimal(9, XUnit.XDAG).toPlainString()); log.debug("Start payment..."); transaction(hashLow, receipt, sendAmount, keyPos, transactionInfoSender); - // paymentsToNodesMap.put(new Address(hashLow, XDAG_FIELD_IN, nodeAmount, false), - // wallet.getAccount(keyPos)); + paymentsToNodesMap.put(new Address(hashLow, XDAG_FIELD_IN, nodeAmount, false), + wallet.getAccount(keyPos)); } else { log.debug("The balance of block {} is insufficient and rewards will not be distributed. Maybe this block " + "has been rollback. send balance:{}", From d4718952933e5158997d4fdfbf771be16ab16ffb Mon Sep 17 00:00:00 2001 From: dkrsgood Date: Wed, 6 Mar 2024 16:03:54 +0800 Subject: [PATCH 8/8] add log --- src/main/java/io/xdag/pool/PoolAwardManagerImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java index 1a07726bc..a73e6aed0 100644 --- a/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java +++ b/src/main/java/io/xdag/pool/PoolAwardManagerImpl.java @@ -215,6 +215,8 @@ public void doPayments(Bytes32 hashLow, XAmount allAmount, Bytes32 poolWalletAdd transaction(hashLow, receipt, sendAmount, keyPos, transactionInfoSender); paymentsToNodesMap.put(new Address(hashLow, XDAG_FIELD_IN, nodeAmount, false), wallet.getAccount(keyPos)); + log.info("The node's reward block was successfully placed,block hash:{},current Map size:{}", + hashLow.toHexString(), paymentsToNodesMap.size()); } else { log.debug("The balance of block {} is insufficient and rewards will not be distributed. Maybe this block " + "has been rollback. send balance:{}",