Created
August 18, 2023 15:56
-
-
Save lontivero/1ab5e42dff7d2e6c93fdd2a6f1eff9d8 to your computer and use it in GitHub Desktop.
Analyze Prison
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "nuget:NBitcoin" | |
#r "nuget:Microsoft.Extensions.Hosting.Abstractions" | |
#r "<WalletWasabi-Repo-Path>/WalletWasabi/bin/Debug/net7.0/WalletWasabi.dll" | |
open System | |
open System.IO | |
open NBitcoin | |
open WalletWasabi | |
open WalletWasabi.WabiSabi | |
open WalletWasabi.WabiSabi.Backend | |
open WalletWasabi.WabiSabi.Backend.DoSPrevention | |
open WalletWasabi.WabiSabi.Backend.Rounds.CoinJoinStorage | |
open System.Threading.Channels | |
let offenders = File.ReadAllLines "./Prison.txt" |> Seq.map Offender.FromStringLine | |
let config = WabiSabiConfig "./WabiSabiConfig.json" | |
let dosConfig = DoSConfiguration( | |
config.DoSSeverity.ToDecimal(MoneyUnit.BTC), | |
config.DoSMinTimeForFailedToVerify, | |
config.DoSMinTimeForCheating, | |
config.DoSMinTimeInPrison, | |
(decimal) config.DoSPenaltyFactorForDisruptingConfirmation, | |
(decimal) config.DoSPenaltyFactorForDisruptingSigning, | |
(decimal) config.DoSPenaltyFactorForDisruptingByDoubleSpending) | |
let coinjoinIdStore = InMemoryCoinJoinIdStore Seq.empty<uint256> | |
let prison = Prison (dosConfig, coinjoinIdStore, Seq.empty<Offender>, Channel.CreateUnbounded<Offender>().Writer) | |
for offender in offenders do | |
prison.Punish offender | |
let bt = prison.GetBanTimePeriod offender.OutPoint | |
printfn "%A %A = %A" offender bt.StartTime bt.Duration | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment