Skip to content

Commit

Permalink
Merge pull request #320 from Junze888/develop
Browse files Browse the repository at this point in the history
Fix the endless Link Bug cause  by non-mining nodes in the mainnet.
  • Loading branch information
LucasMLK authored Jun 27, 2024
2 parents 550f523 + c412d99 commit cf3cbcb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/main/java/io/xdag/core/BlockchainImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,10 @@ public synchronized ImportResult tryToConnect(Block block) {
// result = ImportResult.IMPORTED_EXTRA;
} else {
saveBlock(block);
orphanBlockStore.addOrphan(block);
// prohibited non-mining node set Tx pool
if (kernel.getConfig().getEnableGenerateBlock()) {
orphanBlockStore.addOrphan(block);
}
xdagStats.nnoref++;
}
blockStore.saveXdagStatus(xdagStats);
Expand Down Expand Up @@ -1543,7 +1546,9 @@ public void startCheckMain(long period) {
}

public void checkState() {
if (kernel.getXdagState() == XdagState.SDST || XdagState.STST == kernel.getXdagState() || XdagState.SYNC == kernel.getXdagState()) {
// Prohibit Non-mining nodes generate link blocks
if (kernel.getConfig().getEnableGenerateBlock() &&
(kernel.getXdagState() == XdagState.SDST || XdagState.STST == kernel.getXdagState() || XdagState.SYNC == kernel.getXdagState())) {
checkOrphan();
}
checkMain();
Expand Down

0 comments on commit cf3cbcb

Please sign in to comment.