Use RoundState log methods
MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
@@ -145,21 +145,19 @@ public class CoinJoinClient
try
{
- string round = roundState.BlameOf == 0 ? "Round" : "Blame Round";
-
try
{
registeredAliceClientAndCircuits = await ProceedWithInputRegistrationPhaseAsync(smartCoins, roundState, cancellationToken).ConfigureAwait(false);
}
catch (UnexpectedRoundPhaseException ex)
{
- Logger.LogInfo($"{round} ({roundId}): Registration phase ended by the coordinator: '{ex.Message}'.");
+ roundState.LogInfo($"Registration phase ended by the coordinator: '{ex.Message}'.");
return new CoinJoinResult(false);
}
if (!registeredAliceClientAndCircuits.Any())
{
- Logger.LogInfo($"{round} ({roundId}): There are no available Alices to participate with.");
+ roundState.LogInfo("There are no available Alices to participate with.");
return new CoinJoinResult(false);
}
@@ -176,7 +174,7 @@ public class CoinJoinClient
var wasTxBroadcast = finalRoundState.WasTransactionBroadcast
? $"'{finalRoundState.WasTransactionBroadcast}', Coinjoin TxId: ({unsignedCoinJoin.GetHash()})"
: $"'{finalRoundState.WasTransactionBroadcast}'";
- Logger.LogDebug($"{round} ({roundId}): {round} Ended - WasTransactionBroadcast: {wasTxBroadcast}.");
+ roundState.LogDebug($"Ended - WasTransactionBroadcast: {wasTxBroadcast}.");
LogCoinJoinSummary(registeredAliceClients, outputTxOuts, unsignedCoinJoin, finalRoundState);
@@ -233,8 +231,7 @@ public class CoinJoinClient
// Gets the list of scheduled dates/time in the remaining available time frame when each alice has to be registered.
var remainingTimeForRegistration = roundState.InputRegistrationEnd - DateTimeOffset.UtcNow;
- string round = roundState.BlameOf == 0 ? "Round" : "Blame Round";
- Logger.LogDebug($"{round} ({roundState.Id}): Input registration started - it will end in: {remainingTimeForRegistration:hh\\:mm\\:ss}.");
+ roundState.LogDebug($"Input registration started - it will end in: {remainingTimeForRegistration:hh\\:mm\\:ss}.");
var scheduledDates = GetScheduledDates(smartCoins.Count(), roundState.InputRegistrationEnd);
@@ -354,10 +351,7 @@ public class CoinJoinClient
var totalNetworkFee = inputNetworkFee + outputNetworkFee;
var totalCoordinationFee = Money.Satoshis(registeredAliceClients.Where(a => a.IsPayingZeroCoordinationFee).Sum(a => roundState.CoordinationFeeRate.GetFee(a.SmartCoin.Amount)));
- string round = roundState.BlameOf == 0 ? "Round" : "Blame Round";
-
string[] summary = new string[] {
- $"{round} ({roundState.Id}):",
$"\tInput total: {totalInputAmount.ToString(true, false)} Eff: {totalEffectiveInputAmount.ToString(true, false)} NetwFee: {inputNetworkFee.ToString(true, false)} CoordFee: {totalCoordinationFee.ToString(true)}",
$"\tOutpu total: {totalOutputAmount.ToString(true, false)} Eff: {totalEffectiveOutputAmount.ToString(true, false)} NetwFee: {outputNetworkFee.ToString(true, false)}",
$"\tTotal diff : {totalDifference.ToString(true, false)}",
@@ -365,7 +359,7 @@ public class CoinJoinClient
$"\tTotal fee : {totalNetworkFee.ToString(true, false)}"
};
- Logger.LogDebug(string.Join(Environment.NewLine, summary));
+ roundState.LogDebug(string.Join(Environment.NewLine, summary));
}
internal static ImmutableList<SmartCoin> SelectCoinsForRound(IEnumerable<SmartCoin> coins, MultipartyTransactionParameters parameters, bool consolidationMode, int minAnonScoreTarget, WasabiRandom rnd)
@@ -527,25 +521,23 @@ public class CoinJoinClient
DependencyGraph dependencyGraph = DependencyGraph.ResolveCredentialDependencies(inputEffectiveValuesAndSizes, outputTxOuts, roundState.FeeRate, roundState.CoordinationFeeRate, roundState.MaxVsizeAllocationPerAlice);
DependencyGraphTaskScheduler scheduler = new(dependencyGraph);
- string round = roundState.BlameOf == 0 ? "Round" : "Blame Round";
-
// Re-issuances.
var bobClient = CreateBobClient(roundState);
- Logger.LogInfo($"{round} ({roundState.Id}): Starting reissuances.");
+ roundState.LogInfo("Starting reissuances.");
var combinedToken = combinedCts.Token;
await scheduler.StartReissuancesAsync(registeredAliceClients, bobClient, combinedToken).ConfigureAwait(false);
// Output registration.
- Logger.LogDebug($"{round} ({roundState.Id}): Output registration started - it will end in: {outputRegistrationEndTime - DateTimeOffset.UtcNow:hh\\:mm\\:ss}.");
+ roundState.LogDebug($"Output registration started - it will end in: {outputRegistrationEndTime - DateTimeOffset.UtcNow:hh\\:mm\\:ss}.");
var outputRegistrationScheduledDates = GetScheduledDates(outputTxOuts.Count(), outputRegistrationEndTime, MaximumRequestDelay);
await scheduler.StartOutputRegistrationsAsync(outputTxOuts, bobClient, KeyChain, outputRegistrationScheduledDates, combinedToken).ConfigureAwait(false);
- Logger.LogDebug($"{round} ({roundState.Id}): Outputs({outputTxOuts.Count()}) were registered.");
+ roundState.LogDebug($"Outputs({outputTxOuts.Count()}) were registered.");
// ReadyToSign.
- Logger.LogDebug($"{round} ({roundState.Id}): ReadyToSign phase started - it will end in: {readyToSignEndTime - DateTimeOffset.UtcNow:hh\\:mm\\:ss}.");
+ roundState.LogDebug($"ReadyToSign phase started - it will end in: {readyToSignEndTime - DateTimeOffset.UtcNow:hh\\:mm\\:ss}.");
await ReadyToSignAsync(registeredAliceClients, readyToSignEndTime, combinedToken).ConfigureAwait(false);
- Logger.LogDebug($"{round} ({roundState.Id}): Alices({registeredAliceClients.Length}) are ready to sign.");
+ roundState.LogDebug($"Alices({registeredAliceClients.Length}) are ready to sign.");
return outputTxOuts;
}
@@ -559,9 +551,7 @@ public class CoinJoinClient
using CancellationTokenSource phaseTimeoutCts = new(remainingTime + ExtraPhaseTimeoutMargin);
using CancellationTokenSource combinedCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, phaseTimeoutCts.Token);
- string round = roundState.BlameOf == 0 ? "Round" : "Blame Round";
-
- Logger.LogDebug($"{round} ({roundId}): Transaction signing phase started - it will end in: {signingStateEndTime - DateTimeOffset.UtcNow:hh\\:mm\\:ss}.");
+ roundState.LogDebug($"Transaction signing phase started - it will end in: {signingStateEndTime - DateTimeOffset.UtcNow:hh\\:mm\\:ss}.");
var signingState = roundState.Assert<SigningState>();
var unsignedCoinJoin = signingState.CreateUnsignedTransaction();
@@ -569,13 +559,15 @@ public class CoinJoinClient
// Sanity check.
if (!SanityCheck(outputTxOuts, unsignedCoinJoin))
{
+ string round = roundState.BlameOf == 0 ? "Round" : "Blame Round";
+
throw new InvalidOperationException($"{round} ({roundState.Id}): My output is missing.");
}
// Send signature.
var combinedToken = combinedCts.Token;
await SignTransactionAsync(registeredAliceClients, unsignedCoinJoin, signingStateEndTime, combinedToken).ConfigureAwait(false);
- Logger.LogDebug($"{round} ({roundId}): Alices({registeredAliceClients.Length}) have signed the coinjoin tx.");
+ roundState.LogDebug($"Alices({registeredAliceClients.Length}) have signed the coinjoin tx.");
return unsignedCoinJoin;
}

Use RoundState log methods