Add logging to CoinJoinClient
MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
WalletWasabi/WabiSabi/Client/CoinJoinClient.cs
@@ -123,17 +123,24 @@ namespace WalletWasabi.WabiSabi.Client
// Re-issuances.
var bobClient = CreateBobClient(roundState);
+ Logger.LogInfo($"Round ({roundState.Id}), Starting reissuances.");
await scheduler.StartReissuancesAsync(registeredAliceClients, bobClient, cancellationToken).ConfigureAwait(false);
// Output registration.
roundState = await RoundStatusUpdater.CreateRoundAwaiter(roundState.Id, rs => rs.Phase == Phase.OutputRegistration, cancellationToken).ConfigureAwait(false);
+ Logger.LogDebug($"Round ({roundState.Id}): Output registration phase started.");
+
await scheduler.StartOutputRegistrationsAsync(outputTxOuts, bobClient, cancellationToken).ConfigureAwait(false);
+ Logger.LogDebug($"Round ({roundState.Id}): Outputs({outputTxOuts.Count()}) successfully registered.");
// ReadyToSign.
await ReadyToSignAsync(registeredAliceClients, cancellationToken).ConfigureAwait(false);
+ Logger.LogDebug($"Round ({roundState.Id}): Alices({registeredAliceClients.Length}) successfully signalled ready to sign.");
// Signing.
roundState = await RoundStatusUpdater.CreateRoundAwaiter(roundState.Id, rs => rs.Phase == Phase.TransactionSigning, cancellationToken).ConfigureAwait(false);
+ Logger.LogDebug($"Round ({roundState.Id}): Transaction signing phase started.");
+
var signingState = roundState.Assert<SigningState>();
var unsignedCoinJoin = signingState.CreateUnsignedTransaction();
@@ -145,8 +152,10 @@ namespace WalletWasabi.WabiSabi.Client
// Send signature.
await SignTransactionAsync(registeredAliceClients, unsignedCoinJoin, roundState, cancellationToken).ConfigureAwait(false);
+ Logger.LogDebug($"Round ({roundState.Id}): Alices({registeredAliceClients.Length}) successfully signed the CoinJoin tx.");
var finalRoundState = await RoundStatusUpdater.CreateRoundAwaiter(s => s.Id == roundState.Id && s.Phase == Phase.Ended, cancellationToken).ConfigureAwait(false);
+ Logger.LogDebug($"Round ({roundState.Id}): Round Ended - WasTransactionBroadcast: '{finalRoundState.WasTransactionBroadcast}'.");
return finalRoundState.WasTransactionBroadcast;
}
@@ -195,6 +204,9 @@ namespace WalletWasabi.WabiSabi.Client
// 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;
+
+ Logger.LogDebug($"Round ({roundState.Id}): Input registration started, it will end in {remainingTimeForRegistration.TotalMinutes} minutes.");
+
var scheduledDates = remainingTimeForRegistration.SamplePoisson(smartCoins.Count());
// Creates scheduled tasks (tasks that wait until the specified date/time and then perform the real registration)
@@ -202,7 +214,11 @@ namespace WalletWasabi.WabiSabi.Client
scheduledDates,
async (coin, date) =>
{
- await Task.Delay(date - DateTimeOffset.UtcNow, cancellationToken).ConfigureAwait(false);
+ var delay = date - DateTimeOffset.UtcNow;
+ if (delay > TimeSpan.Zero)
+ {
+ await Task.Delay(delay, cancellationToken).ConfigureAwait(false);
+ }
return await RegisterInputAsync(coin, cancellationToken).ConfigureAwait(false);
}).ToImmutableArray();
@@ -251,6 +267,8 @@ namespace WalletWasabi.WabiSabi.Client
// Gets the list of scheduled dates/time in the remaining available time frame when each alice has to sign.
var transactionSigningTimeFrame = roundState.TransactionSigningTimeout - RoundStatusUpdater.Period;
+ Logger.LogDebug($"Round ({roundState.Id}): Signing phase started, it will end in {transactionSigningTimeFrame.TotalMinutes} minutes.");
+
var scheduledDates = transactionSigningTimeFrame.SamplePoisson(aliceClients.Count());
// Creates scheduled tasks (tasks that wait until the specified date/time and then perform the real registration)
@@ -258,7 +276,11 @@ namespace WalletWasabi.WabiSabi.Client
scheduledDates,
async (alice, date) =>
{
- await Task.Delay(date - DateTimeOffset.UtcNow, cancellationToken).ConfigureAwait(false);
+ var delay = date - DateTimeOffset.UtcNow;
+ if (delay > TimeSpan.Zero)
+ {
+ await Task.Delay(delay, cancellationToken).ConfigureAwait(false);
+ }
return await SignTransactionAsync(alice, cancellationToken).ConfigureAwait(false);
}).ToImmutableArray();

Add logging to CoinJoinClient