Skip to content

Commit

Permalink
Fix sealed mining Block overwritten
Browse files Browse the repository at this point in the history
  • Loading branch information
AionJayT committed Sep 10, 2020
1 parent 6b66b7a commit ed30290
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions modAionImpl/src/org/aion/zero/impl/types/AionBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -456,4 +456,8 @@ public void updateHeaderDifficulty(byte[] diff) {
.withDifficulty(diff)
.build();
}

public boolean notSealed() {
return Arrays.equals(header.getSolution(), new byte[A0BlockHeader.SOLUTIONSIZE]) && Arrays.equals(header.getNonce(), ByteUtil.EMPTY_WORD);
}
}
2 changes: 1 addition & 1 deletion modApiServer/src/org/aion/api/server/rpc/ApiWeb3Aion.java
Original file line number Diff line number Diff line change
Expand Up @@ -2612,7 +2612,7 @@ public RpcMsg stratum_submitblock(Object _params) {
&& !JSONObject.NULL.equals(hdrHash)) {
// Grab copy of best block
AionBlock bestBlock = ac.getBlockchain().getCachingMiningBlockTemplate(hexStringToBytes((String) hdrHash));
if (bestBlock != null) {
if (bestBlock != null && bestBlock.notSealed()) {
try {
bestBlock.seal(hexStringToBytes(nce + ""), hexStringToBytes(soln + ""));
} catch (Exception e) {
Expand Down

0 comments on commit ed30290

Please sign in to comment.