-
Notifications
You must be signed in to change notification settings - Fork 101
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor context system #264
Changes from 22 commits
bc9cd5c
831bbde
3573f4c
69fdb65
e8f52ee
8782e0c
c2c6462
afa375c
bcec533
ffed4c2
ed1d370
2c7e172
10fab42
af4f134
f9eb123
a8df760
92ca2c4
c70c9ba
b01c316
0d186e3
495f817
bf69b15
7e3ae9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -31,6 +31,8 @@ | |||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.crypto.BLSPublicKey; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.crypto.BLSSecretKey; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.crypto.BLSSignature; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.manager.DashSystem; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.quorums.ChainLocksHandler; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.script.ScriptPattern; | ||||||||||||||||||||||||||||||||||||||||
import org.slf4j.Logger; | ||||||||||||||||||||||||||||||||||||||||
import org.slf4j.LoggerFactory; | ||||||||||||||||||||||||||||||||||||||||
|
@@ -149,12 +151,12 @@ public void setConfirmedHeight(int confirmedHeight) { | |||||||||||||||||||||||||||||||||||||||
this.confirmedHeight = confirmedHeight; | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
public boolean isExpired(StoredBlock block) { | ||||||||||||||||||||||||||||||||||||||||
public boolean isExpired(StoredBlock block, ChainLocksHandler chainLocksHandler) { | ||||||||||||||||||||||||||||||||||||||||
// expire confirmed DSTXes after ~1h since confirmation or chainlocked confirmation | ||||||||||||||||||||||||||||||||||||||||
if (confirmedHeight == -1 || block.getHeight() < confirmedHeight) return false; // not mined yet | ||||||||||||||||||||||||||||||||||||||||
if (block.getHeight() - confirmedHeight > 24) return true; // mined more than an hour ago | ||||||||||||||||||||||||||||||||||||||||
// TODO: this may crash | ||||||||||||||||||||||||||||||||||||||||
return Context.get().chainLockHandler.hasChainLock(block.getHeight(), block.getHeader().getHash()); | ||||||||||||||||||||||||||||||||||||||||
return chainLocksHandler.hasChainLock(block.getHeight(), block.getHeader().getHash()); | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+154
to
+159
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Several improvements needed in the isExpired method.
Consider applying these improvements: + private static final int EXPIRY_BLOCK_COUNT = 24; // Number of blocks representing ~1 hour
+
public boolean isExpired(StoredBlock block, ChainLocksHandler chainLocksHandler) {
+ if (chainLocksHandler == null) {
+ throw new IllegalArgumentException("chainLocksHandler cannot be null");
+ }
// expire confirmed DSTXes after ~1h since confirmation or chainlocked confirmation
if (confirmedHeight == -1 || block.getHeight() < confirmedHeight) return false; // not mined yet
- if (block.getHeight() - confirmedHeight > 24) return true; // mined more than an hour ago
+ if (block.getHeight() - confirmedHeight > EXPIRY_BLOCK_COUNT) return true; // mined more than an hour ago
- // TODO: this may crash
+ // TODO: Document specific crash scenario: [your explanation here]
return chainLocksHandler.hasChainLock(block.getHeight(), block.getHeader().getHash());
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
public boolean isValidStructure() { | ||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
import org.bitcoinj.coinjoin.listeners.MixingStartedListener; | ||
import org.bitcoinj.coinjoin.listeners.SessionCompleteListener; | ||
import org.bitcoinj.coinjoin.listeners.SessionStartedListener; | ||
import org.bitcoinj.coinjoin.utils.CoinJoinManager; | ||
import org.bitcoinj.core.AbstractBlockChain; | ||
import org.bitcoinj.core.Coin; | ||
import org.bitcoinj.core.Context; | ||
|
@@ -36,8 +37,10 @@ | |
import org.bitcoinj.core.VerificationException; | ||
import org.bitcoinj.core.listeners.NewBestBlockListener; | ||
import org.bitcoinj.evolution.Masternode; | ||
import org.bitcoinj.evolution.MasternodeMetaDataManager; | ||
import org.bitcoinj.evolution.SimplifiedMasternodeList; | ||
import org.bitcoinj.evolution.SimplifiedMasternodeListEntry; | ||
import org.bitcoinj.evolution.SimplifiedMasternodeListManager; | ||
import org.bitcoinj.utils.ListenerRegistration; | ||
import org.bitcoinj.utils.Threading; | ||
import org.bitcoinj.wallet.Wallet; | ||
|
@@ -88,6 +91,10 @@ public class CoinJoinClientManager implements WalletCoinsReceivedEventListener { | |
private String strAutoDenomResult = ""; | ||
|
||
private final Context context; | ||
private final MasternodeSync masternodeSync; | ||
private final CoinJoinManager coinJoinManager; | ||
private final SimplifiedMasternodeListManager masternodeListManager; | ||
private final MasternodeMetaDataManager masternodeMetaDataManager; | ||
private final WalletEx mixingWallet; | ||
|
||
// Keep track of current block height | ||
|
@@ -104,8 +111,8 @@ public class CoinJoinClientManager implements WalletCoinsReceivedEventListener { | |
= new CopyOnWriteArrayList<>(); | ||
|
||
private boolean waitForAnotherBlock() { | ||
if (context.masternodeSync.hasSyncFlag(MasternodeSync.SYNC_FLAGS.SYNC_GOVERNANCE) && | ||
!mixingWallet.getContext().masternodeSync.isBlockchainSynced()) return true; | ||
if (masternodeSync.hasSyncFlag(MasternodeSync.SYNC_FLAGS.SYNC_GOVERNANCE) && | ||
!masternodeSync.isBlockchainSynced()) return true; | ||
|
||
if (CoinJoinClientOptions.isMultiSessionEnabled()) return false; | ||
|
||
|
@@ -124,23 +131,31 @@ private boolean checkAutomaticBackup() { | |
|
||
public int cachedNumBlocks = Integer.MAX_VALUE; // used for the overview screen | ||
|
||
public CoinJoinClientManager(Wallet wallet) { | ||
public CoinJoinClientManager(Wallet wallet, MasternodeSync masternodeSync, CoinJoinManager coinJoinManager, SimplifiedMasternodeListManager masternodeListManager, MasternodeMetaDataManager masternodeMetaDataManager) { | ||
checkArgument(wallet instanceof WalletEx); | ||
mixingWallet = (WalletEx) wallet; | ||
context = wallet.getContext(); | ||
this.masternodeSync = masternodeSync; | ||
this.coinJoinManager = coinJoinManager; | ||
this.masternodeMetaDataManager = masternodeMetaDataManager; | ||
this.masternodeListManager = masternodeListManager; | ||
Comment on lines
+134
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Review constructor overloading and parameter order Two constructors have been updated to include additional parameters. Ensure that the parameter order is consistent and that all necessary initializations are performed: public CoinJoinClientManager(Wallet wallet, MasternodeSync masternodeSync, CoinJoinManager coinJoinManager, SimplifiedMasternodeListManager masternodeListManager, MasternodeMetaDataManager masternodeMetaDataManager) {
// ...
}
public CoinJoinClientManager(WalletEx wallet, MasternodeSync masternodeSync, CoinJoinManager coinJoinManager, SimplifiedMasternodeListManager masternodeListManager, MasternodeMetaDataManager masternodeMetaDataManager) {
// ...
} Consider unifying the constructors or using inheritance to reduce code duplication. |
||
mixingWallet.addCoinsReceivedEventListener(this); | ||
} | ||
|
||
public CoinJoinClientManager(WalletEx wallet) { | ||
public CoinJoinClientManager(WalletEx wallet, MasternodeSync masternodeSync, CoinJoinManager coinJoinManager, SimplifiedMasternodeListManager masternodeListManager, MasternodeMetaDataManager masternodeMetaDataManager) { | ||
mixingWallet = wallet; | ||
context = wallet.getContext(); | ||
this.masternodeSync = masternodeSync; | ||
this.coinJoinManager = coinJoinManager; | ||
this.masternodeMetaDataManager = masternodeMetaDataManager; | ||
this.masternodeListManager = masternodeListManager; | ||
mixingWallet.addCoinsReceivedEventListener(this); | ||
} | ||
|
||
public void processMessage(Peer from, Message message, boolean enable_bip61) { | ||
if (!CoinJoinClientOptions.isEnabled()) | ||
return; | ||
if (context.masternodeSync.hasSyncFlag(MasternodeSync.SYNC_FLAGS.SYNC_GOVERNANCE) && !context.masternodeSync.isBlockchainSynced()) | ||
if (masternodeSync.hasSyncFlag(MasternodeSync.SYNC_FLAGS.SYNC_GOVERNANCE) && !masternodeSync.isBlockchainSynced()) | ||
return; | ||
|
||
if (message instanceof CoinJoinStatusUpdate || | ||
|
@@ -225,17 +240,17 @@ public boolean doAutomaticDenominating(boolean dryRun) { | |
if (!CoinJoinClientOptions.isEnabled() || (!dryRun && !isMixing())) | ||
return false; | ||
|
||
if (context.masternodeSync.hasSyncFlag(MasternodeSync.SYNC_FLAGS.SYNC_GOVERNANCE) && !mixingWallet.getContext().masternodeSync.isBlockchainSynced()) { | ||
if (masternodeSync.hasSyncFlag(MasternodeSync.SYNC_FLAGS.SYNC_GOVERNANCE) && !masternodeSync.isBlockchainSynced()) { | ||
strAutoDenomResult = "Can't mix while sync in progress."; | ||
return false; | ||
} | ||
|
||
if (!dryRun && mixingWallet.isEncrypted() && context.coinJoinManager.requestKeyParameter(mixingWallet) == null) { | ||
if (!dryRun && mixingWallet.isEncrypted() && coinJoinManager.requestKeyParameter(mixingWallet) == null) { | ||
strAutoDenomResult = "Wallet is locked."; | ||
return false; | ||
} | ||
|
||
int mnCountEnabled = context.masternodeListManager.getListAtChainTip().getValidMNsCount(); | ||
int mnCountEnabled = masternodeListManager.getListAtChainTip().getValidMNsCount(); | ||
|
||
// If we've used 90% of the Masternode list then drop the oldest first ~30% | ||
int thresholdHigh = (int) (mnCountEnabled * 0.9); | ||
|
@@ -274,7 +289,7 @@ public boolean doAutomaticDenominating(boolean dryRun) { | |
lock.lock(); | ||
try { | ||
if (deqSessions.size() < CoinJoinClientOptions.getSessions()) { | ||
CoinJoinClientSession newSession = new CoinJoinClientSession(mixingWallet); | ||
CoinJoinClientSession newSession = new CoinJoinClientSession(mixingWallet, coinJoinManager, masternodeListManager, masternodeMetaDataManager, masternodeSync); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check new session creation parameters When creating a new CoinJoinClientSession newSession = new CoinJoinClientSession(mixingWallet, coinJoinManager, masternodeListManager, masternodeMetaDataManager, masternodeSync); Ensure that the |
||
log.info("creating new session: {}: ", newSession.getId()); | ||
for (ListenerRegistration<SessionCompleteListener> listener : sessionCompleteListeners) { | ||
newSession.addSessionCompleteListener(listener.executor, listener.listener); | ||
|
@@ -378,7 +393,7 @@ public void addUsedMasternode(Sha256Hash proTxHash) { | |
masternodesUsed.add(proTxHash); | ||
} | ||
public Masternode getRandomNotUsedMasternode() { | ||
SimplifiedMasternodeList mnList = context.masternodeListManager.getListAtChainTip(); | ||
SimplifiedMasternodeList mnList = masternodeListManager.getListAtChainTip(); | ||
|
||
int nCountEnabled = mnList.getValidMNsCount(); | ||
int nCountNotExcluded = nCountEnabled - masternodesUsed.size(); | ||
|
@@ -443,8 +458,8 @@ public void doMaintenance() { | |
if (!CoinJoinClientOptions.isEnabled()) | ||
return; | ||
|
||
if (context.masternodeSync.hasSyncFlag(MasternodeSync.SYNC_FLAGS.SYNC_GOVERNANCE) | ||
&&!context.masternodeSync.isBlockchainSynced()) | ||
if (masternodeSync.hasSyncFlag(MasternodeSync.SYNC_FLAGS.SYNC_GOVERNANCE) | ||
&&!masternodeSync.isBlockchainSynced()) | ||
return; | ||
|
||
nTick++; | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -15,13 +15,16 @@ | |||||||||||||||||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||||||||||||||||||
package org.bitcoinj.coinjoin; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.coinjoin.utils.CoinJoinManager; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.core.Context; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.core.MasternodeSync; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.core.Peer; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.core.Sha256Hash; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.core.Utils; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.evolution.Masternode; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.evolution.MasternodeMetaDataManager; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.evolution.SimplifiedMasternodeList; | ||||||||||||||||||||||||||||||||||||||||
import org.bitcoinj.evolution.SimplifiedMasternodeListManager; | ||||||||||||||||||||||||||||||||||||||||
import org.slf4j.Logger; | ||||||||||||||||||||||||||||||||||||||||
import org.slf4j.LoggerFactory; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
|
@@ -32,11 +35,19 @@ | |||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
public class CoinJoinClientQueueManager extends CoinJoinBaseManager { | ||||||||||||||||||||||||||||||||||||||||
private final Context context; | ||||||||||||||||||||||||||||||||||||||||
private final CoinJoinManager coinJoinManager; | ||||||||||||||||||||||||||||||||||||||||
private final SimplifiedMasternodeListManager masternodeListManager; | ||||||||||||||||||||||||||||||||||||||||
private final MasternodeMetaDataManager masternodeMetaDataManager; | ||||||||||||||||||||||||||||||||||||||||
private final MasternodeSync masternodeSync; | ||||||||||||||||||||||||||||||||||||||||
private final Logger log = LoggerFactory.getLogger(CoinJoinClientManager.class); | ||||||||||||||||||||||||||||||||||||||||
private final HashMap<Sha256Hash, Long> spammingMasternodes = new HashMap(); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
public CoinJoinClientQueueManager(Context context) { | ||||||||||||||||||||||||||||||||||||||||
public CoinJoinClientQueueManager(Context context, CoinJoinManager coinJoinManager, SimplifiedMasternodeListManager masternodeListManager, MasternodeMetaDataManager masternodeMetaDataManager, MasternodeSync masternodeSync) { | ||||||||||||||||||||||||||||||||||||||||
super(); | ||||||||||||||||||||||||||||||||||||||||
this.coinJoinManager = coinJoinManager; | ||||||||||||||||||||||||||||||||||||||||
this.masternodeListManager = masternodeListManager; | ||||||||||||||||||||||||||||||||||||||||
this.masternodeMetaDataManager = masternodeMetaDataManager; | ||||||||||||||||||||||||||||||||||||||||
this.masternodeSync = masternodeSync; | ||||||||||||||||||||||||||||||||||||||||
this.context = context; | ||||||||||||||||||||||||||||||||||||||||
Comment on lines
+45
to
51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add null checks for constructor parameters. The constructor should validate that none of its parameters are null to prevent NullPointerException during runtime. public CoinJoinClientQueueManager(Context context, CoinJoinManager coinJoinManager, SimplifiedMasternodeListManager masternodeListManager, MasternodeMetaDataManager masternodeMetaDataManager, MasternodeSync masternodeSync) {
super();
+ if (context == null) throw new IllegalArgumentException("context cannot be null");
+ if (coinJoinManager == null) throw new IllegalArgumentException("coinJoinManager cannot be null");
+ if (masternodeListManager == null) throw new IllegalArgumentException("masternodeListManager cannot be null");
+ if (masternodeMetaDataManager == null) throw new IllegalArgumentException("masternodeMetaDataManager cannot be null");
+ if (masternodeSync == null) throw new IllegalArgumentException("masternodeSync cannot be null");
this.coinJoinManager = coinJoinManager;
this.masternodeListManager = masternodeListManager;
this.masternodeMetaDataManager = masternodeMetaDataManager;
this.masternodeSync = masternodeSync;
this.context = context;
} 📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
|
@@ -69,7 +80,7 @@ public void processDSQueue(Peer from, CoinJoinQueue dsq, boolean enable_bip61) { | |||||||||||||||||||||||||||||||||||||||
if (dsq.isTimeOutOfBounds()) | ||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
SimplifiedMasternodeList mnList = context.masternodeListManager.getListAtChainTip(); | ||||||||||||||||||||||||||||||||||||||||
SimplifiedMasternodeList mnList = masternodeListManager.getListAtChainTip(); | ||||||||||||||||||||||||||||||||||||||||
Masternode dmn = mnList.getMN(dsq.getProTxHash()); | ||||||||||||||||||||||||||||||||||||||||
if (dmn == null) | ||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||
|
@@ -83,24 +94,24 @@ public void processDSQueue(Peer from, CoinJoinQueue dsq, boolean enable_bip61) { | |||||||||||||||||||||||||||||||||||||||
if (dsq.isReady() && isTrySubmitDenominate(dmn)) { | ||||||||||||||||||||||||||||||||||||||||
log.info("coinjoin: DSQUEUE: {} is ready on masternode {}", dsq, dmn.getService()); | ||||||||||||||||||||||||||||||||||||||||
} else { | ||||||||||||||||||||||||||||||||||||||||
long nLastDsq = context.masternodeMetaDataManager.getMetaInfo(dmn.getProTxHash()).getLastDsq(); | ||||||||||||||||||||||||||||||||||||||||
long nDsqThreshold = context.masternodeMetaDataManager.getDsqThreshold(dmn.getProTxHash(), mnList.getValidMNsCount()); | ||||||||||||||||||||||||||||||||||||||||
long nLastDsq = masternodeMetaDataManager.getMetaInfo(dmn.getProTxHash()).getLastDsq(); | ||||||||||||||||||||||||||||||||||||||||
long nDsqThreshold = masternodeMetaDataManager.getDsqThreshold(dmn.getProTxHash(), mnList.getValidMNsCount()); | ||||||||||||||||||||||||||||||||||||||||
log.info(COINJOIN_EXTRA, "coinjoin: DSQUEUE -- lastDsq: {} dsqThreshold: {} dsqCount: {}", | ||||||||||||||||||||||||||||||||||||||||
nLastDsq, nDsqThreshold, context.masternodeMetaDataManager.getDsqCount()); | ||||||||||||||||||||||||||||||||||||||||
nLastDsq, nDsqThreshold, masternodeMetaDataManager.getDsqCount()); | ||||||||||||||||||||||||||||||||||||||||
// don't allow a few nodes to dominate the queuing process | ||||||||||||||||||||||||||||||||||||||||
if (nLastDsq != 0 && nDsqThreshold > context.masternodeMetaDataManager.getDsqCount()) { | ||||||||||||||||||||||||||||||||||||||||
if (nLastDsq != 0 && nDsqThreshold > masternodeMetaDataManager.getDsqCount()) { | ||||||||||||||||||||||||||||||||||||||||
if (!spammingMasternodes.containsKey(dsq.getProTxHash())) { | ||||||||||||||||||||||||||||||||||||||||
spammingMasternodes.put(dsq.getProTxHash(), Utils.currentTimeMillis()); | ||||||||||||||||||||||||||||||||||||||||
log.info(COINJOIN_EXTRA, "coinjoin: DSQUEUE: Masternode {} is sending too many dsq messages", dmn.getProTxHash()); | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
context.masternodeMetaDataManager.allowMixing(dmn.getProTxHash()); | ||||||||||||||||||||||||||||||||||||||||
masternodeMetaDataManager.allowMixing(dmn.getProTxHash()); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
log.info("coinjoin: DSQUEUE: new {} from masternode {}", dsq, dmn.getService().getAddr()); | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
context.coinJoinManager.coinJoinClientManagers.values().stream().anyMatch(new Predicate<CoinJoinClientManager>() { | ||||||||||||||||||||||||||||||||||||||||
coinJoinManager.coinJoinClientManagers.values().stream().anyMatch(new Predicate<CoinJoinClientManager>() { | ||||||||||||||||||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||||||||||||||||||
public boolean test(CoinJoinClientManager coinJoinClientManager) { | ||||||||||||||||||||||||||||||||||||||||
return coinJoinClientManager.markAlreadyJoinedQueueAsTried(dsq); | ||||||||||||||||||||||||||||||||||||||||
|
@@ -119,7 +130,7 @@ public boolean test(CoinJoinClientManager coinJoinClientManager) { | |||||||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
private boolean isTrySubmitDenominate(Masternode dmn) { | ||||||||||||||||||||||||||||||||||||||||
return context.coinJoinManager.coinJoinClientManagers.values().stream().anyMatch(new Predicate<CoinJoinClientManager>() { | ||||||||||||||||||||||||||||||||||||||||
return coinJoinManager.coinJoinClientManagers.values().stream().anyMatch(new Predicate<CoinJoinClientManager>() { | ||||||||||||||||||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||||||||||||||||||
public boolean test(CoinJoinClientManager coinJoinClientManager) { | ||||||||||||||||||||||||||||||||||||||||
return coinJoinClientManager.trySubmitDenominate(dmn.getService()); | ||||||||||||||||||||||||||||||||||||||||
|
@@ -131,11 +142,11 @@ public void doMaintenance() { | |||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
if (!CoinJoinClientOptions.isEnabled()) | ||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||
if (context.masternodeSync == null) | ||||||||||||||||||||||||||||||||||||||||
if (masternodeSync == null) | ||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
if (context.masternodeSync.hasSyncFlag(MasternodeSync.SYNC_FLAGS.SYNC_GOVERNANCE) && | ||||||||||||||||||||||||||||||||||||||||
!context.masternodeSync.isBlockchainSynced()) | ||||||||||||||||||||||||||||||||||||||||
if (masternodeSync.hasSyncFlag(MasternodeSync.SYNC_FLAGS.SYNC_GOVERNANCE) && | ||||||||||||||||||||||||||||||||||||||||
!masternodeSync.isBlockchainSynced()) | ||||||||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||
checkQueue(); | ||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consider adding null validation for chainLocksHandler.
The methods accept chainLocksHandler but don't validate it for null.
Add null validation to both methods:
📝 Committable suggestion