Skip to content

Commit

Permalink
fix: reduce logging and use markers (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
HashEngineering authored Mar 19, 2024
1 parent 9c66d59 commit 4606d5f
Show file tree
Hide file tree
Showing 16 changed files with 113 additions and 94 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/bitcoinj/coinjoin/CoinJoin.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ public static boolean isCollateralValid(Transaction txCollateral, boolean checkI
}
nValueIn = nValueIn.add(tx.getOutput(txin.getOutpoint().getIndex()).getValue());
} else {
log.info("coinjoin: -- Unknown inputs in collateral transaction, txCollateral={}", txCollateral); /* Continued */
log.info("coinjoin: Unknown inputs in collateral transaction, txCollateral={}", txCollateral); /* Continued */
return false;
}
}

//collateral transactions are required to pay out a small fee to the miners
if (nValueIn.minus(nValueOut).isLessThan(getCollateralAmount())) {
log.info("coinjoin: did not include enough fees in transaction: fees: {}, txCollateral={}", nValueOut.minus(nValueIn), txCollateral); /* Continued */
log.info("coinjoin: did not include enough fees in transaction: fees: {}, txCollateral={}", nValueOut.minus(nValueIn), txCollateral); /* Continued */
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected void bitcoinSerializeToStream(OutputStream stream) throws IOException
@Override
public String toString() {
return String.format(
"CoinJoinAccept(denomination=%d, txCollateral=%s)",
"CoinJoinAccept(denom=%d, txCol=%s)",
denomination,
txCollateral.getTxId()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.util.Iterator;
import java.util.concurrent.locks.ReentrantLock;

import static org.bitcoinj.coinjoin.CoinJoinConstants.COINJOIN_EXTRA;

public class CoinJoinBaseManager {

private final Logger log = LoggerFactory.getLogger(CoinJoinBaseManager.class);
Expand All @@ -50,7 +52,7 @@ protected void checkQueue() {
while (it.hasNext()) {
CoinJoinQueue queue = it.next();
if (queue.isTimeOutOfBounds(Utils.currentTimeSeconds())) {
log.info("Removing a queue {}", queue);
log.info(COINJOIN_EXTRA, "Removing a queue {}", queue);
it.remove();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.ReentrantLock;

import static org.bitcoinj.coinjoin.CoinJoinConstants.COINJOIN_EXTRA;
import static org.bitcoinj.coinjoin.PoolMessage.ERR_ALREADY_HAVE;
import static org.bitcoinj.coinjoin.PoolMessage.ERR_DENOM;
import static org.bitcoinj.coinjoin.PoolMessage.ERR_FEES;
Expand Down Expand Up @@ -137,7 +138,7 @@ public ValidInOuts check(TransactionOutput txout) {
}

for (TransactionInput txin :vin){
log.info(" txin={}", txin);
log.info(COINJOIN_EXTRA, " txin={}", txin);

if (txin.getOutpoint() == null) {
log.info("coinjoin: ERROR: invalid input!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static org.bitcoinj.coinjoin.CoinJoinConstants.COINJOIN_AUTO_TIMEOUT_MAX;
import static org.bitcoinj.coinjoin.CoinJoinConstants.COINJOIN_AUTO_TIMEOUT_MIN;
import static org.bitcoinj.coinjoin.CoinJoinConstants.COINJOIN_EXTRA;

public class CoinJoinClientManager implements WalletCoinsReceivedEventListener {
private static final Logger log = LoggerFactory.getLogger(CoinJoinClientManager.class);
Expand Down Expand Up @@ -293,7 +294,7 @@ public boolean doAutomaticDenominating(boolean dryRun) {
if (!dryRun && waitForAnotherBlock()) {
if (Utils.currentTimeMillis() - lastTimeReportTooRecent > 15000 ) {
strAutoDenomResult = "Last successful action was too recent.";
log.info("DoAutomaticDenominating -- {}", strAutoDenomResult);
log.info("DoAutomaticDenominating: {}", strAutoDenomResult);
lastTimeReportTooRecent = Utils.currentTimeMillis();
}
return false;
Expand All @@ -317,7 +318,8 @@ public boolean trySubmitDenominate(MasternodeAddress mnAddr) {
session.submitDenominate();
return true;
} else {
log.info("mixingMasternode {} != mnAddr {} or {} != {}", mnMixing != null ? mnMixing.getService().getSocketAddress() : "null", mnAddr.getSocketAddress(),
log.info(COINJOIN_EXTRA, "mixingMasternode {} != mnAddr {} or {} != {}",
mnMixing != null ? mnMixing.getService().getSocketAddress() : "null", mnAddr.getSocketAddress(),
session.getState(), PoolState.POOL_STATE_QUEUE);
}
}
Expand Down Expand Up @@ -407,7 +409,7 @@ public void processMN(SimplifiedMasternodeListEntry mn) {
continue;
}

log.info("coinjoin: found, masternode={}", dmn.getProTxHash());
log.info("coinjoin: found, masternode={}", dmn.getProTxHash().toString().substring(0, 16));
return dmn;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.util.HashMap;
import java.util.function.Predicate;

import static org.bitcoinj.coinjoin.CoinJoinConstants.COINJOIN_EXTRA;

public class CoinJoinClientQueueManager extends CoinJoinBaseManager {
private final Context context;
private final Logger log = LoggerFactory.getLogger(CoinJoinClientManager.class);
Expand All @@ -51,7 +53,7 @@ public void processDSQueue(Peer from, CoinJoinQueue dsq, boolean enable_bip61) {
// no way the same mn can send another dsq with the same readiness this soon
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());
log.info(COINJOIN_EXTRA, "coinjoin: DSQUEUE: Peer {} is sending WAY too many dsq messages for a masternode {}", from.getAddress().getAddr(), dsq.getProTxHash());
}
return;
}
Expand All @@ -62,7 +64,7 @@ public void processDSQueue(Peer from, CoinJoinQueue dsq, boolean enable_bip61) {
}


log.info("coinjoin: DSQUEUE -- {} new", dsq);
log.info(COINJOIN_EXTRA, "coinjoin: DSQUEUE -- {} new", dsq);

if (dsq.isTimeOutOfBounds())
return;
Expand All @@ -79,24 +81,24 @@ public void processDSQueue(Peer from, CoinJoinQueue dsq, boolean enable_bip61) {

// if the queue is ready, submit if we can
if (dsq.isReady() && isTrySubmitDenominate(dmn)) {
log.info("coinjoin: DSQUEUE -- CoinJoin queue ({}) is ready on masternode {}", dsq, dmn.getService());
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());
log.info("coinjoin: DSQUEUE -- lastDsq: {} dsqThreshold: {} dsqCount: {}", nLastDsq, nDsqThreshold, context.masternodeMetaDataManager.getDsqCount());
log.info(COINJOIN_EXTRA, "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()) {
if (!spammingMasternodes.containsKey(dsq.getProTxHash())) {
spammingMasternodes.put(dsq.getProTxHash(), Utils.currentTimeMillis());
log.info("coinjoin: DSQUEUE -- Masternode {} is sending too many dsq messages", dmn.getProTxHash());
log.info(COINJOIN_EXTRA, "coinjoin: DSQUEUE: Masternode {} is sending too many dsq messages", dmn.getProTxHash());
}
return;
}

context.masternodeMetaDataManager.allowMixing(dmn.getProTxHash());

log.info("coinjoin: DSQUEUE -- new CoinJoin queue ({}) from masternode {}", dsq, dmn.getService());

log.info("coinjoin: DSQUEUE: new {} from masternode {}", dsq, dmn.getService().getAddr());

context.coinJoinManager.coinJoinClientManagers.values().stream().anyMatch(new Predicate<CoinJoinClientManager>() {
@Override
Expand Down
Loading

0 comments on commit 4606d5f

Please sign in to comment.