Skip to content

Commit

Permalink
Make roundId unique
Browse files Browse the repository at this point in the history
Resolves #803
  • Loading branch information
nopara73 committed Nov 10, 2018
1 parent d0cd699 commit 303b5d2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion WalletWasabi/Models/ChaumianCoinJoin/CcjRound.cs
Expand Up @@ -14,7 +14,7 @@ namespace WalletWasabi.Models.ChaumianCoinJoin
{ {
public class CcjRound public class CcjRound
{ {
private static long RoundCount = 0; // First time initializes (so the first constructor will increment it and we'll start from 1.) public static long RoundCount;
public long RoundId { get; } public long RoundId { get; }


public RPCClient RpcClient { get; } public RPCClient RpcClient { get; }
Expand Down
33 changes: 33 additions & 0 deletions WalletWasabi/Services/CcjCoordinator.cs
Expand Up @@ -112,6 +112,27 @@ public CcjCoordinator(Network network, string folderPath, RPCClient rpc, CcjRoun
File.Delete(CoinJoinsFilePath); File.Delete(CoinJoinsFilePath);
} }
} }

try
{
string roundCountFilePath = Path.Combine(folderPath, "RoundCount.txt");
if (File.Exists(roundCountFilePath))
{
string roundCount = File.ReadAllText(roundCountFilePath);
CcjRound.RoundCount = long.Parse(roundCount);
}
else
{
// First time initializes (so the first constructor will increment it and we'll start from 1.)
CcjRound.RoundCount = 0;
}
}
catch (Exception ex)
{
CcjRound.RoundCount = 0;
Logger.LogInfo<CcjCoordinator>($"{nameof(CcjRound.RoundCount)} file was corrupt. Resetting to 0.");
Logger.LogDebug<CcjCoordinator>(ex);
}
} }


public async Task ProcessBlockAsync(Block block) public async Task ProcessBlockAsync(Block block)
Expand Down Expand Up @@ -347,6 +368,18 @@ protected virtual void Dispose(bool disposing)
round.StatusChanged -= Round_StatusChangedAsync; round.StatusChanged -= Round_StatusChangedAsync;
round.CoinJoinBroadcasted -= Round_CoinJoinBroadcasted; round.CoinJoinBroadcasted -= Round_CoinJoinBroadcasted;
} }

try
{
string roundCountFilePath = Path.Combine(FolderPath, "RoundCount.txt");

IoHelpers.EnsureContainingDirectoryExists(roundCountFilePath);
File.WriteAllText(roundCountFilePath, CcjRound.RoundCount.ToString());
}
catch (Exception ex)
{
Logger.LogDebug<CcjCoordinator>(ex);
}
} }
} }


Expand Down

0 comments on commit 303b5d2

Please sign in to comment.