Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Firefly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Firefly(XDAGj-v0.8.4)



## Firefly v0.8.4

- Fix abnormally high generation of orphan blocks issues.



### Notable changes in this release:

-Implement thread safety for increasing or decreasing xxnoref to ensure normal block production.

### Bug fixes:

-Fixed an issue with inconsistent synchronization of orphan block statistics in a multi-threaded environment.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.xdag</groupId>
<artifactId>xdagj</artifactId>
<version>0.8.3</version>
<version>0.8.4</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/io/xdag/core/BlockchainImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ public synchronized ImportResult tryToConnect(Block block) {
} else {
saveBlock(block);
dealOrphan(block);
xdagStats.nnoref++;
incrementNnoref();
}
blockStore.saveXdagStatus(xdagStats);

Expand Down Expand Up @@ -605,7 +605,7 @@ public void rollTx(Block block) {
if ((txBlock.getInfo().flags & BI_REF) != 0) {
txBlock=getBlockByHash(link.getAddress(),false);
updateBlockFlag(txBlock, BI_REF, false);
xdagStats.nnoref++;
incrementNnoref();
blockStore.saveXdagStatus(xdagStats);
}
mBlockTx.remove(link.addressHash);
Expand All @@ -622,7 +622,7 @@ public void rollTx(Block block) {
if ((txBlock.getInfo().flags & BI_REF) == 0) continue;
txBlock=getBlockByHash(link.getAddress(),false);
updateBlockFlag(txBlock, BI_REF, false);
xdagStats.nnoref++;
incrementNnoref();
blockStore.saveXdagStatus(xdagStats);
log.debug("roll main txBlock :{} , txBlock :{} , mBlockTx size :{}", block.getHashLow(), link.addressHash, mBlockTx.size());
break;
Expand Down Expand Up @@ -1737,7 +1737,7 @@ public void removeOrphan(Bytes32 hashlow, OrphanRemoveActions action) {

orphanBlockStore.deleteFromQueue(b, isTxBlock(b), nonce, fee, address);
orphanBlockStore.deleteByKey(b.getHashLow().toArray(), isTxBlock(b), nonce, fee, address);
xdagStats.nnoref--;
decrementNnoref();
}
// Update this block's flag
updateBlockFlag(b, BI_REF, true);
Expand Down Expand Up @@ -1991,6 +1991,7 @@ public void startCheckMain(long period) {

public void checkState() {
// Prohibit Non-mining nodes generate link blocks
xdagStats.setNnoref(orphanBlockStore.getOrphanSize());
if (kernel.getConfig().getEnableGenerateBlock() &&
(kernel.getXdagState() == XdagState.SDST || XdagState.STST == kernel.getXdagState() || XdagState.SYNC == kernel.getXdagState())) {
checkOrphan();
Expand Down Expand Up @@ -2271,6 +2272,13 @@ public List<Block> listMinedBlocks(int count) {
return res;
}

public synchronized void decrementNnoref() {
xdagStats.nnoref--;
}
public synchronized void incrementNnoref() {
xdagStats.nnoref++;
}

enum OrphanRemoveActions {
ORPHAN_REMOVE_NORMAL, ORPHAN_REMOVE_REUSE, ORPHAN_REMOVE_EXTRA
}
Expand Down
Loading