When validating online accounts, enforce mempow if the online account's timestamp is after the feature trigger.

This commit is contained in:
CalDescent 2022-09-23 19:45:59 +01:00
parent 6d9e6e8d4c
commit ea4f4d949b

View File

@ -325,8 +325,9 @@ public class OnlineAccountsManager {
return false; return false;
} }
// Validate mempow if feature trigger is active // Validate mempow if feature trigger is active (or if online account's timestamp is past the trigger timestamp)
if (now >= BlockChain.getInstance().getOnlineAccountsMemoryPoWTimestamp()) { long memoryPoWStartTimestamp = BlockChain.getInstance().getOnlineAccountsMemoryPoWTimestamp();
if (now >= memoryPoWStartTimestamp || onlineAccountTimestamp >= memoryPoWStartTimestamp) {
if (!getInstance().verifyMemoryPoW(onlineAccountData, now)) { if (!getInstance().verifyMemoryPoW(onlineAccountData, now)) {
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;
@ -628,7 +629,8 @@ public class OnlineAccountsManager {
} }
public boolean verifyMemoryPoW(OnlineAccountData onlineAccountData, Long timestamp) { public boolean verifyMemoryPoW(OnlineAccountData onlineAccountData, Long timestamp) {
if (!isMemoryPoWActive(timestamp)) { long memoryPoWStartTimestamp = BlockChain.getInstance().getOnlineAccountsMemoryPoWTimestamp();
if (timestamp < memoryPoWStartTimestamp && onlineAccountData.getTimestamp() < memoryPoWStartTimestamp) {
// Not active yet, so treat it as valid // Not active yet, so treat it as valid
return true; return true;
} }