From f55efe38c59aa7673decf12d947a26fdc8b6a0fe Mon Sep 17 00:00:00 2001 From: kennycud Date: Mon, 18 Nov 2024 15:09:43 -0800 Subject: [PATCH] Removed logging statements to demonstrate order of operations to others. Added optimizations for the canMint() method. This is a quick fix and a more comprehensive fix will be done in the future. --- src/main/java/org/qortal/account/Account.java | 37 ++++++++----------- .../hsqldb/HSQLDBNameRepository.java | 9 ----- 2 files changed, 15 insertions(+), 31 deletions(-) diff --git a/src/main/java/org/qortal/account/Account.java b/src/main/java/org/qortal/account/Account.java index d0a29c7d..735bb30c 100644 --- a/src/main/java/org/qortal/account/Account.java +++ b/src/main/java/org/qortal/account/Account.java @@ -222,8 +222,6 @@ public class Account { int removeNameCheckHeight = BlockChain.getInstance().getRemoveOnlyMintWithNameHeight(); String myAddress = accountData.getAddress(); - List myName = nameRepository.getNamesByOwner(myAddress); - boolean isMember = groupRepository.memberExists(groupIdToMint, myAddress); if (accountData == null) return false; @@ -232,45 +230,40 @@ public class Account { if (blockchainHeight < nameCheckHeight && level >= levelToMint) return true; - LOGGER.info("Calling myName.isEmpty(): myAddress = " + myAddress); - // Can only mint if have registered a name - if (blockchainHeight >= nameCheckHeight && blockchainHeight < groupCheckHeight && level >= levelToMint && !myName.isEmpty()) + if (blockchainHeight >= nameCheckHeight && blockchainHeight < groupCheckHeight && level >= levelToMint && !nameRepository.getNamesByOwner(myAddress).isEmpty()) return true; // Can only mint if have registered a name and is member of minter group id - if (blockchainHeight >= groupCheckHeight && blockchainHeight < removeNameCheckHeight && level >= levelToMint && !myName.isEmpty() && isMember) + if (blockchainHeight >= groupCheckHeight && blockchainHeight < removeNameCheckHeight && level >= levelToMint && groupRepository.memberExists(groupIdToMint, myAddress) && !nameRepository.getNamesByOwner(myAddress).isEmpty() && groupRepository.memberExists(groupIdToMint, myAddress)) return true; // Can only mint if is member of minter group id - if (blockchainHeight >= removeNameCheckHeight && level >= levelToMint && isMember) + if (blockchainHeight >= removeNameCheckHeight && level >= levelToMint && groupRepository.memberExists(groupIdToMint, myAddress)) + return true; + + // if you aren't a legit founder by this point, then you can't mint + if( !(Account.isFounder(accountData.getFlags()) && + accountData.getBlocksMintedPenalty() == 0)) + return false; + + if (blockchainHeight < nameCheckHeight ) return true; // Founders needs to pass same tests like minters - if (blockchainHeight < nameCheckHeight && - Account.isFounder(accountData.getFlags()) && - accountData.getBlocksMintedPenalty() == 0) - return true; - if (blockchainHeight >= nameCheckHeight && blockchainHeight < groupCheckHeight && - Account.isFounder(accountData.getFlags()) && - accountData.getBlocksMintedPenalty() == 0 && - !myName.isEmpty()) + !nameRepository.getNamesByOwner(myAddress).isEmpty()) return true; if (blockchainHeight >= groupCheckHeight && blockchainHeight < removeNameCheckHeight && - Account.isFounder(accountData.getFlags()) && - accountData.getBlocksMintedPenalty() == 0 && - !myName.isEmpty() && - isMember) + !nameRepository.getNamesByOwner(myAddress).isEmpty() && + groupRepository.memberExists(groupIdToMint, myAddress)) return true; if (blockchainHeight >= removeNameCheckHeight && - Account.isFounder(accountData.getFlags()) && - accountData.getBlocksMintedPenalty() == 0 && - isMember) + groupRepository.memberExists(groupIdToMint, myAddress)) return true; return false; diff --git a/src/main/java/org/qortal/repository/hsqldb/HSQLDBNameRepository.java b/src/main/java/org/qortal/repository/hsqldb/HSQLDBNameRepository.java index 25a6a385..06e41663 100644 --- a/src/main/java/org/qortal/repository/hsqldb/HSQLDBNameRepository.java +++ b/src/main/java/org/qortal/repository/hsqldb/HSQLDBNameRepository.java @@ -1,8 +1,5 @@ package org.qortal.repository.hsqldb; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.qortal.account.Account; import org.qortal.data.naming.NameData; import org.qortal.repository.DataException; import org.qortal.repository.NameRepository; @@ -14,8 +11,6 @@ import java.util.List; public class HSQLDBNameRepository implements NameRepository { - private static final Logger LOGGER = LogManager.getLogger(HSQLDBNameRepository.class); - protected HSQLDBRepository repository; public HSQLDBNameRepository(HSQLDBRepository repository) { @@ -269,8 +264,6 @@ public class HSQLDBNameRepository implements NameRepository { @Override public List getNamesByOwner(String owner, Integer limit, Integer offset, Boolean reverse) throws DataException { - LOGGER.info("Executing getNamesByOwner: owner = " + owner); - StringBuilder sql = new StringBuilder(512); sql.append("SELECT name, reduced_name, data, registered_when, updated_when, " @@ -313,8 +306,6 @@ public class HSQLDBNameRepository implements NameRepository { return names; } catch (SQLException e) { throw new DataException("Unable to fetch account's names from repository", e); - } finally { - LOGGER.info("Executed getNamesByOwner: owner = " + owner); } }