Skip to content

Commit

Permalink
Extend DoS functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
nopara73 committed Nov 2, 2018
1 parent 8d538e4 commit 52621a6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion WalletWasabi/Services/CcjCoordinator.cs
Expand Up @@ -54,7 +54,7 @@ public CcjCoordinator(Network network, string folderPath, RPCClient rpc, CcjRoun

Directory.CreateDirectory(FolderPath);

UtxoReferee = new UtxoReferee(Network, FolderPath, RpcClient);
UtxoReferee = new UtxoReferee(Network, FolderPath, RpcClient, RoundConfig);

// Initialize RsaKey
string rsaKeyPath = Path.Combine(FolderPath, "RsaKey.json");
Expand Down
12 changes: 10 additions & 2 deletions WalletWasabi/Services/UtxoReferee.cs
Expand Up @@ -9,6 +9,7 @@
using System.Threading.Tasks;
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
using WalletWasabi.Models.ChaumianCoinJoin;

namespace WalletWasabi.Services
{
Expand All @@ -22,16 +23,18 @@ public class UtxoReferee
public string BannedUtxosFilePath => Path.Combine(FolderPath, $"BannedUtxos{Network}.txt");

public RPCClient RpcClient { get; }

public Network Network { get; }

public CcjRoundConfig RoundConfig { get; }

public string FolderPath { get; }

public UtxoReferee(Network network, string folderPath, RPCClient rpc)
public UtxoReferee(Network network, string folderPath, RPCClient rpc, CcjRoundConfig roundConfig)
{
Network = Guard.NotNull(nameof(network), network);
FolderPath = Guard.NotNullOrEmptyOrWhitespace(nameof(folderPath), folderPath, trim: true);
RpcClient = Guard.NotNull(nameof(rpc), rpc);
RoundConfig = Guard.NotNull(nameof(roundConfig), roundConfig);

BannedUtxos = new ConcurrentDictionary<OutPoint, (int severity, DateTimeOffset timeOfBan)>();

Expand Down Expand Up @@ -85,6 +88,11 @@ public UtxoReferee(Network network, string folderPath, RPCClient rpc)

public async Task BanUtxosAsync(int severity, DateTimeOffset timeOfBan, params OutPoint[] toBan)
{
if (RoundConfig.DosSeverity == 0)
{
return;
}

var lines = new List<string>();
foreach (var utxo in toBan)
{
Expand Down

0 comments on commit 52621a6

Please sign in to comment.