Skip to content

Instantly share code, notes, and snippets.

@lontivero
Created August 18, 2023 15:56
Show Gist options
  • Save lontivero/1ab5e42dff7d2e6c93fdd2a6f1eff9d8 to your computer and use it in GitHub Desktop.
Save lontivero/1ab5e42dff7d2e6c93fdd2a6f1eff9d8 to your computer and use it in GitHub Desktop.
Analyze Prison
#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