Use onlineAccountTimestamp for all mempow hard fork related code in OnlineAccountsManager too.

This commit is contained in:
CalDescent 2022-09-04 11:51:24 +01:00
parent 8879ec5bb4
commit 23423102e7
2 changed files with 8 additions and 8 deletions

View File

@ -1076,7 +1076,7 @@ public class Block {
// Validate the rest // Validate the rest
for (OnlineAccountData onlineAccount : onlineAccounts) for (OnlineAccountData onlineAccount : onlineAccounts)
if (!OnlineAccountsManager.getInstance().verifyMemoryPoW(onlineAccount, this.blockData.getTimestamp())) if (!OnlineAccountsManager.getInstance().verifyMemoryPoW(onlineAccount))
return ValidationResult.ONLINE_ACCOUNT_NONCE_INCORRECT; return ValidationResult.ONLINE_ACCOUNT_NONCE_INCORRECT;
} }

View File

@ -305,8 +305,8 @@ public class OnlineAccountsManager {
} }
// Validate mempow if feature trigger is active // Validate mempow if feature trigger is active
if (now >= BlockChain.getInstance().getOnlineAccountsMemoryPoWTimestamp()) { if (onlineAccountTimestamp >= BlockChain.getInstance().getOnlineAccountsMemoryPoWTimestamp()) {
if (!getInstance().verifyMemoryPoW(onlineAccountData, now)) { if (!getInstance().verifyMemoryPoW(onlineAccountData)) {
LOGGER.trace(() -> String.format("Rejecting online reward-share for account %s due to invalid PoW nonce", mintingAccount.getAddress())); LOGGER.trace(() -> String.format("Rejecting online reward-share for account %s due to invalid PoW nonce", mintingAccount.getAddress()));
return false; return false;
} }
@ -542,7 +542,7 @@ public class OnlineAccountsManager {
// Compute nonce // Compute nonce
Integer nonce; Integer nonce;
if (isMemoryPoWActive(NTP.getTime())) { if (isMemoryPoWActive(onlineAccountsTimestamp)) {
try { try {
nonce = this.computeMemoryPoW(mempowBytes, publicKey, onlineAccountsTimestamp); nonce = this.computeMemoryPoW(mempowBytes, publicKey, onlineAccountsTimestamp);
if (nonce == null) { if (nonce == null) {
@ -565,7 +565,7 @@ public class OnlineAccountsManager {
OnlineAccountData ourOnlineAccountData = new OnlineAccountData(onlineAccountsTimestamp, signature, publicKey, nonce); OnlineAccountData ourOnlineAccountData = new OnlineAccountData(onlineAccountsTimestamp, signature, publicKey, nonce);
// Make sure to verify before adding // Make sure to verify before adding
if (verifyMemoryPoW(ourOnlineAccountData, NTP.getTime())) { if (verifyMemoryPoW(ourOnlineAccountData)) {
ourOnlineAccounts.add(ourOnlineAccountData); ourOnlineAccounts.add(ourOnlineAccountData);
} }
} }
@ -615,7 +615,7 @@ public class OnlineAccountsManager {
} }
private Integer computeMemoryPoW(byte[] bytes, byte[] publicKey, long onlineAccountsTimestamp) throws TimeoutException { private Integer computeMemoryPoW(byte[] bytes, byte[] publicKey, long onlineAccountsTimestamp) throws TimeoutException {
if (!isMemoryPoWActive(NTP.getTime())) { if (!isMemoryPoWActive(onlineAccountsTimestamp)) {
LOGGER.info("Mempow start timestamp not yet reached, and onlineAccountsMemPoWEnabled not enabled in settings"); LOGGER.info("Mempow start timestamp not yet reached, and onlineAccountsMemPoWEnabled not enabled in settings");
return null; return null;
} }
@ -641,8 +641,8 @@ public class OnlineAccountsManager {
return nonce; return nonce;
} }
public boolean verifyMemoryPoW(OnlineAccountData onlineAccountData, Long timestamp) { public boolean verifyMemoryPoW(OnlineAccountData onlineAccountData) {
if (!isMemoryPoWActive(timestamp)) { if (!isMemoryPoWActive(onlineAccountData.getTimestamp())) {
// Not active yet, so treat it as valid // Not active yet, so treat it as valid
return true; return true;
} }