Skip to content

Commit

Permalink
fix(coinjoin): reduce logging
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering committed Mar 9, 2024
1 parent c96c58b commit d79ea54
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,20 @@
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.SimplifiedMasternodeList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.function.Predicate;

public class CoinJoinClientQueueManager extends CoinJoinBaseManager {
private final Context context;
private final Logger log = LoggerFactory.getLogger(CoinJoinClientManager.class);
private final HashMap<Sha256Hash, Long> spammingMasternodes = new HashMap();

public CoinJoinClientQueueManager(Context context) {
super();
Expand All @@ -45,7 +49,10 @@ public void processDSQueue(Peer from, CoinJoinQueue dsq, boolean enable_bip61) {
}
if (q.isReady() == dsq.isReady() && q.getProTxHash().equals(dsq.getProTxHash())) {
// no way the same mn can send another dsq with the same readiness this soon
log.debug("coinjoin: DSQUEUE -- Peer {} is sending WAY too many dsq messages for a masternode {}", from.getAddress().getAddr(), dsq.getProTxHash());
if (!spammingMasternodes.containsKey(dsq.getProTxHash())) {
spammingMasternodes.put(dsq.getProTxHash(), Utils.currentTimeMillis());
log.info("coinjoin: DSQUEUE -- Peer {} is sending WAY too many dsq messages for a masternode {}", from.getAddress().getAddr(), dsq.getProTxHash());

Check warning on line 54 in core/src/main/java/org/bitcoinj/coinjoin/CoinJoinClientQueueManager.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/bitcoinj/coinjoin/CoinJoinClientQueueManager.java#L53-L54

Added lines #L53 - L54 were not covered by tests
}
return;
}
}
Expand Down Expand Up @@ -79,7 +86,10 @@ public void processDSQueue(Peer from, CoinJoinQueue dsq, boolean enable_bip61) {
log.info("coinjoin: DSQUEUE -- lastDsq: {} dsqThreshold: {} dsqCount: {}", nLastDsq, nDsqThreshold, context.masternodeMetaDataManager.getDsqCount());
// don't allow a few nodes to dominate the queuing process
if (nLastDsq != 0 && nDsqThreshold > context.masternodeMetaDataManager.getDsqCount()) {
log.info("coinjoin: DSQUEUE -- Masternode {} is sending too many dsq messages", dmn.getProTxHash());
if (!spammingMasternodes.containsKey(dsq.getProTxHash())) {
spammingMasternodes.put(dsq.getProTxHash(), Utils.currentTimeMillis());
log.info("coinjoin: DSQUEUE -- Masternode {} is sending too many dsq messages", dmn.getProTxHash());

Check warning on line 91 in core/src/main/java/org/bitcoinj/coinjoin/CoinJoinClientQueueManager.java

View check run for this annotation

Codecov / codecov/patch

core/src/main/java/org/bitcoinj/coinjoin/CoinJoinClientQueueManager.java#L90-L91

Added lines #L90 - L91 were not covered by tests
}
return;
}

Expand Down Expand Up @@ -127,5 +137,7 @@ public void doMaintenance() {
return;

checkQueue();

spammingMasternodes.entrySet().removeIf(entry -> entry.getValue() + CoinJoinConstants.COINJOIN_QUEUE_TIMEOUT * 1000 < Utils.currentTimeMillis());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1356,16 +1356,16 @@ public boolean doAutomaticDenominating(boolean fDryRun) {
log.info("coinjoin: wallet stats:\n{}", bal);

log.info("coinjoin: current stats:\n" +
" nValueMin: {}\n" +
" min: {}\n" +
" myTrusted: {}\n" +
" nBalanceAnonymizable: {}\n" +
" nBalanceAnonymized: {}\n" +
" balanceAnonymizable: {}\n" +
" balanceAnonymized: {}\n" +
" balanceNeedsAnonymized: {}\n" +
" nBalanceAnonimizableNonDenom: {}\n" +
" nBalanceDenominatedConf: {}\n" +
" nBalanceDenominatedUnconf: {}\n" +
" nBalanceDenominated: {}\n" +
" nBalanceToDenominate: {}\n",
" balanceAnonimizableNonDenom: {}\n" +
" balanceDenominatedConf: {}\n" +
" balanceDenominatedUnconf: {}\n" +
" balanceDenominated: {}\n" +
" balanceToDenominate: {}\n",
nValueMin.toFriendlyString(),
bal.getMyTrusted().toFriendlyString(),
nBalanceAnonymizable.toFriendlyString(),
Expand Down

0 comments on commit d79ea54

Please sign in to comment.