public async Task InitializeAsync(string workFolderPath, Network network) { using (BenchmarkLogger.Measure()) { WorkFolderPath = Guard.NotNullOrEmptyOrWhitespace(nameof(workFolderPath), workFolderPath, trim: true); IoHelpers.EnsureDirectoryExists(WorkFolderPath); Network = Guard.NotNull(nameof(network), network); IndexStore = new IndexStore(); TransactionStore = new AllTransactionStore(); var networkWorkFolderPath = Path.Combine(WorkFolderPath, Network.ToString()); var indexStoreFolderPath = Path.Combine(networkWorkFolderPath, "IndexStore"); SmartHeaderChain = new SmartHeaderChain(); MempoolService = new MempoolService(); var initTasks = new[] { IndexStore.InitializeAsync(indexStoreFolderPath, Network, SmartHeaderChain), TransactionStore.InitializeAsync(networkWorkFolderPath, Network) }; await Task.WhenAll(initTasks).ConfigureAwait(false); IsInitialized = true; } }
public Global(string dataDir, string torLogsFile, Config config, UiConfig uiConfig, WalletManager walletManager) { using (BenchmarkLogger.Measure()) { CrashReporter = new CrashReporter(); StoppingCts = new CancellationTokenSource(); DataDir = dataDir; Config = config; UiConfig = uiConfig; TorLogsFile = torLogsFile; Logger.InitializeDefaults(Path.Combine(DataDir, "Logs.txt")); HostedServices = new HostedServices(); WalletManager = walletManager; LegalDocuments = LegalDocuments.TryLoadAgreed(DataDir); WalletManager.OnDequeue += WalletManager_OnDequeue; WalletManager.WalletRelevantTransactionProcessed += WalletManager_WalletRelevantTransactionProcessed; var indexStore = new IndexStore(Network, new SmartHeaderChain()); BitcoinStore = new BitcoinStore( Path.Combine(DataDir, "BitcoinStore"), Network, indexStore, new AllTransactionStore(), new MempoolService() ); SingleInstanceChecker = new SingleInstanceChecker(Network); } }
public Global(INotificationManager notificationManager, ITorManager torManager, IDataDirProvider dataDirProvider) { TorManager = torManager; NotificationManager = notificationManager; using (BenchmarkLogger.Measure()) { StoppingCts = new CancellationTokenSource(); DataDir = dataDirProvider.Get(); Directory.CreateDirectory(DataDir); Config = new Config(Path.Combine(DataDir, "Config.json")); UiConfig = new UiConfig(Path.Combine(DataDir, "UiConfig.json")); Logger.InitializeDefaults(Path.Combine(DataDir, "Logs.txt")); UiConfig.LoadOrCreateDefaultFile(); Config.LoadOrCreateDefaultFile(); WalletManager = new WalletManager(Network, new WalletDirectories(DataDir)); WalletManager.OnDequeue += WalletManager_OnDequeue; WalletManager.WalletRelevantTransactionProcessed += WalletManager_WalletRelevantTransactionProcessed; var indexStore = new IndexStore(Network, new SmartHeaderChain()); BitcoinStore = new BitcoinStore( Path.Combine(DataDir, "BitcoinStore"), Network, indexStore, new AllTransactionStore(), new MempoolService() ); } }
public async Task InitializeAsync(string workFolderPath, Network network, string operationName, CancellationToken cancel) { using (BenchmarkLogger.Measure(operationName: operationName)) { WorkFolderPath = Guard.NotNullOrEmptyOrWhitespace(nameof(workFolderPath), workFolderPath, trim: true); Network = Guard.NotNull(nameof(network), network); var transactionsFilePath = Path.Combine(WorkFolderPath, "Transactions.dat"); // In Transactions.dat every line starts with the tx id, so the first character is the best for digest creation. TransactionsFileManager = new IoManager(transactionsFilePath); cancel.ThrowIfCancellationRequested(); using (await TransactionsFileAsyncLock.LockAsync(cancel).ConfigureAwait(false)) { IoHelpers.EnsureDirectoryExists(WorkFolderPath); cancel.ThrowIfCancellationRequested(); if (!TransactionsFileManager.Exists()) { await SerializeAllTransactionsNoLockAsync().ConfigureAwait(false); cancel.ThrowIfCancellationRequested(); } await InitializeTransactionsNoLockAsync(cancel).ConfigureAwait(false); } } }
public Global(string dataDir, string torLogsFile, Config config, UiConfig uiConfig, WalletManager walletManager) { using (BenchmarkLogger.Measure()) { StoppingCts = new CancellationTokenSource(); DataDir = dataDir; Config = config; UiConfig = uiConfig; TorSettings = new TorSettings(DataDir, torLogsFile, distributionFolderPath: EnvironmentHelpers.GetFullBaseDirectory()); Logger.InitializeDefaults(Path.Combine(DataDir, "Logs.txt")); HostedServices = new HostedServices(); WalletManager = walletManager; LegalDocuments = LegalDocuments.TryLoadAgreed(DataDir); WalletManager.OnDequeue += WalletManager_OnDequeue; WalletManager.WalletRelevantTransactionProcessed += WalletManager_WalletRelevantTransactionProcessed; var networkWorkFolderPath = Path.Combine(DataDir, "BitcoinStore", Network.ToString()); var transactionStore = new AllTransactionStore(networkWorkFolderPath, Network); var indexStore = new IndexStore(Path.Combine(networkWorkFolderPath, "IndexStore"), Network, new SmartHeaderChain()); var mempoolService = new MempoolService(); var blocks = new FileSystemBlockRepository(Path.Combine(networkWorkFolderPath, "Blocks"), Network); BitcoinStore = new BitcoinStore(indexStore, transactionStore, mempoolService, blocks); WasabiClientFactory wasabiClientFactory = Config.UseTor ? new WasabiClientFactory(Config.TorSocks5EndPoint, backendUriGetter: () => Config.GetCurrentBackendUri()) : new WasabiClientFactory(torEndPoint: null, backendUriGetter: () => Config.GetFallbackBackendUri()); Synchronizer = new WasabiSynchronizer(Network, BitcoinStore, wasabiClientFactory); } }
static async Task Main(string[] args) { Logger.InitializeDefaults(); ParseArgs(args, out NetworkCredential rpcCred); var rpcConf = new RPCCredentialString { UserPassword = rpcCred }; var client = new RPCClient(rpcConf, Network.Main); using (BenchmarkLogger.Measure(operationName: "Parsing The Blockchain")) { var cjIndexer = new CoinJoinIndexer(client); var days = await cjIndexer.GetDailyStatsAsync(); foreach (var month in days.GroupBy(x => new DateTimeOffset(x.BlockTimeDay.Year, x.BlockTimeDay.Month, 1, 0, 0, 0, TimeSpan.Zero)).OrderBy(x => x.Key)) { Console.WriteLine($"{month.Key.Year}-{month.Key.Month}\tFresh bitcoins: {(int)Money.Satoshis(month.Sum(x => x.NonMixedInputSum)).ToDecimal(MoneyUnit.BTC)},\tNonremixed change: {(int)Money.Satoshis(month.Sum(x => x.NonRemixedChangeSum)).ToDecimal(MoneyUnit.BTC)}\t\tNonremixed <2 anons: {(int)Money.Satoshis(month.Sum(x => x.NonRemixed2AnonSum)).ToDecimal(MoneyUnit.BTC)}\t\tNonremixed <5 anons: {(int)Money.Satoshis(month.Sum(x => x.NonRemixed5AnonSum)).ToDecimal(MoneyUnit.BTC)}\t\tNonremixed <10 anons: {(int)Money.Satoshis(month.Sum(x => x.NonRemixed10AnonSum)).ToDecimal(MoneyUnit.BTC)}"); } await File.WriteAllLinesAsync("DailyStats.txt", days.Select(x => x.ToString())); } Console.WriteLine(); Console.WriteLine("Press a button to exit..."); Console.ReadKey(); }
public async Task InitializeAsync(string workFolderPath, Network network, string operationName) { using (BenchmarkLogger.Measure(operationName: operationName)) { WorkFolderPath = Guard.NotNullOrEmptyOrWhitespace(nameof(workFolderPath), workFolderPath, trim: true); Network = Guard.NotNull(nameof(network), network); Transactions = new Dictionary <uint256, SmartTransaction>(); TransactionsLock = new object(); var fileName = Path.Combine(WorkFolderPath, "Transactions.dat"); var transactionsFilePath = Path.Combine(WorkFolderPath, fileName); TransactionsFileManager = new MutexIoManager(transactionsFilePath); using (await TransactionsFileManager.Mutex.LockAsync().ConfigureAwait(false)) { IoHelpers.EnsureDirectoryExists(WorkFolderPath); if (!TransactionsFileManager.Exists()) { await SerializeAllTransactionsNoMutexAsync().ConfigureAwait(false); } await InitializeTransactionsNoMutexAsync().ConfigureAwait(false); } } }
public async Task InitializeAsync(CancellationToken cancel = default) { using (BenchmarkLogger.Measure()) { using (await IndexLock.LockAsync(cancel).ConfigureAwait(false)) using (await MatureIndexAsyncLock.LockAsync(cancel).ConfigureAwait(false)) using (await ImmatureIndexAsyncLock.LockAsync(cancel).ConfigureAwait(false)) { await EnsureBackwardsCompatibilityAsync().ConfigureAwait(false); if (Network == Network.RegTest) { MatureIndexFileManager.DeleteMe(); // RegTest is not a global ledger, better to delete it. ImmatureIndexFileManager.DeleteMe(); } cancel.ThrowIfCancellationRequested(); if (!MatureIndexFileManager.Exists()) { await MatureIndexFileManager.WriteAllLinesAsync(new[] { StartingFilter.ToLine() }, CancellationToken.None).ConfigureAwait(false); } cancel.ThrowIfCancellationRequested(); await InitializeFiltersAsync(cancel).ConfigureAwait(false); } } }
public async Task InitializeAsync(string workFolderPath, Network network, bool ensureBackwardsCompatibility = true) { using (BenchmarkLogger.Measure()) { WorkFolderPath = Guard.NotNullOrEmptyOrWhitespace(nameof(workFolderPath), workFolderPath, trim: true); Network = Guard.NotNull(nameof(network), network); MempoolStore = new TransactionStore(); ConfirmedStore = new TransactionStore(); Lock = new object(); var mempoolWorkFolder = Path.Combine(WorkFolderPath, "Mempool"); var confirmedWorkFolder = Path.Combine(WorkFolderPath, "ConfirmedTransactions", Constants.ConfirmedTransactionsVersion); var initTasks = new[] { MempoolStore.InitializeAsync(mempoolWorkFolder, Network, $"{nameof(MempoolStore)}.{nameof(MempoolStore.InitializeAsync)}"), ConfirmedStore.InitializeAsync(confirmedWorkFolder, Network, $"{nameof(ConfirmedStore)}.{nameof(ConfirmedStore.InitializeAsync)}") }; await Task.WhenAll(initTasks).ConfigureAwait(false); EnsureConsistency(); if (ensureBackwardsCompatibility) { EnsureBackwardsCompatibility(); } } }
public Global() { using (BenchmarkLogger.Measure()) { StoppingCts = new CancellationTokenSource(); DataDir = EnvironmentHelpers.GetDataDir(Path.Combine("MustardWalletLTC", "Client")); TorLogsFile = Path.Combine(DataDir, "TorLogs.txt"); Directory.CreateDirectory(DataDir); Logger.InitializeDefaults(Path.Combine(DataDir, "Logs.txt")); UiConfig = new UiConfig(Path.Combine(DataDir, "UiConfig.json")); UiConfig.LoadOrCreateDefaultFile(); Config = new Config(Path.Combine(DataDir, "Config.json")); Config.LoadOrCreateDefaultFile(); HostedServices = new HostedServices(); WalletManager = new WalletManager(Network, new WalletDirectories(DataDir)); LegalDocuments = LegalDocuments.TryLoadAgreed(DataDir); WalletManager.OnDequeue += WalletManager_OnDequeue; WalletManager.WalletRelevantTransactionProcessed += WalletManager_WalletRelevantTransactionProcessed; } }
public Global( ITorManager torManager, IDataDirProvider dataDirProvider, Config config, UiConfig uiConfig, ChaincaseWalletManager walletManager, BitcoinStore bitcoinStore, ChaincaseSynchronizer synchronizer, FeeProviders feeProviders ) { _torManager = torManager; _dataDirProvider = dataDirProvider; _config = config; _uiConfig = uiConfig; _walletManager = walletManager; _bitcoinStore = bitcoinStore; _synchronizer = synchronizer; _feeProviders = feeProviders; using (BenchmarkLogger.Measure()) { StoppingCts = new CancellationTokenSource(); Logger.InitializeDefaults(Path.Combine(DataDir, "Logs.txt")); _uiConfig.LoadOrCreateDefaultFile(); } }
public void CalculateSmallerThanMinimumWasabiInputs() { using (BenchmarkLogger.Measure()) { Dictionary <YearMonth, decimal> wasabi = CalculateSmallerThanMinimumWasabiInputs(ScannerFiles.WasabiCoinJoins); DisplayWasabiResults(wasabi); } }
public void CalculateIncome() { using (BenchmarkLogger.Measure()) { Dictionary <YearMonth, Money> wasabi = CalculateWasabiIncome(ScannerFiles.WasabiCoinJoins); Dictionary <YearMonth, Money> samuri = CalculateSamuriIncome(ScannerFiles.SamouraiTx0s); DisplayWasabiSamuriResults(wasabi, samuri); } }
public static async Task <CoreNode> CreateAsync(CoreNodeParams coreNodeParams, CancellationToken cancel) { Guard.NotNull(nameof(coreNodeParams), coreNodeParams); using (BenchmarkLogger.Measure()) { var coreNode = new CoreNode(); coreNode.HostedServices = coreNodeParams.HostedServices; coreNode.DataDir = coreNodeParams.DataDir; coreNode.Network = coreNodeParams.Network; coreNode.MempoolService = coreNodeParams.MempoolService; var configPath = Path.Combine(coreNode.DataDir, "bitcoin.conf"); coreNode.Config = new CoreConfig(); if (File.Exists(configPath)) { var configString = await File.ReadAllTextAsync(configPath).ConfigureAwait(false); coreNode.Config.AddOrUpdate(configString); // Bitcoin Core considers the last entry to be valid. } cancel.ThrowIfCancellationRequested(); var configTranslator = new CoreConfigTranslator(coreNode.Config, coreNode.Network); string rpcUser = configTranslator.TryGetRpcUser(); string rpcPassword = configTranslator.TryGetRpcPassword(); string rpcCookieFilePath = configTranslator.TryGetRpcCookieFile(); string rpcHost = configTranslator.TryGetRpcBind(); int? rpcPort = configTranslator.TryGetRpcPort(); WhiteBind whiteBind = configTranslator.TryGetWhiteBind(); string authString; bool cookieAuth = rpcCookieFilePath is { }; if (cookieAuth) { authString = $"cookiefile={rpcCookieFilePath}"; } else { rpcUser ??= Encoders.Hex.EncodeData(RandomUtils.GetBytes(21)); rpcPassword ??= Encoders.Hex.EncodeData(RandomUtils.GetBytes(21)); authString = $"{rpcUser}:{rpcPassword}"; } coreNode.P2pEndPoint = whiteBind?.EndPoint ?? coreNodeParams.P2pEndPointStrategy.EndPoint; rpcHost ??= coreNodeParams.RpcEndPointStrategy.EndPoint.GetHostOrDefault(); rpcPort ??= coreNodeParams.RpcEndPointStrategy.EndPoint.GetPortOrDefault(); EndPointParser.TryParse($"{rpcHost}:{rpcPort}", coreNode.Network.RPCPort, out EndPoint rpce); coreNode.RpcEndPoint = rpce; var rpcClient = new RPCClient( $"{authString}", coreNode.RpcEndPoint.ToString(coreNode.Network.DefaultPort), coreNode.Network); coreNode.RpcClient = new CachedRpcClient(rpcClient, new MemoryCache(new MemoryCacheOptions { SizeLimit = 1_000 }));
public void CalculatePostMixConsolidation() { using (BenchmarkLogger.Measure()) { Dictionary <YearMonth, decimal> otheri = CalculateAveragePostMixInputs(ScannerFiles.OtherCoinJoinPostMixTxs); Dictionary <YearMonth, decimal> wasabi = CalculateAveragePostMixInputs(ScannerFiles.WasabiPostMixTxs); Dictionary <YearMonth, decimal> samuri = CalculateAveragePostMixInputs(ScannerFiles.SamouraiPostMixTxs); DisplayOtheriWasabiSamuriResults(otheri, wasabi, samuri); } }
public void CalculateEquality() { using (BenchmarkLogger.Measure()) { Dictionary <YearMonth, ulong> otheri = CalculateEquality(ScannerFiles.OtherCoinJoins); Dictionary <YearMonth, ulong> wasabi = CalculateEquality(ScannerFiles.WasabiCoinJoins); Dictionary <YearMonth, ulong> samuri = CalculateEquality(ScannerFiles.SamouraiCoinJoins); DisplayOtheriWasabiSamuriResults(otheri, wasabi, samuri); } }
public void CalculateMonthlyNetworkFeePaidByUserPerCoinjoin() { using (BenchmarkLogger.Measure()) { IDictionary <YearMonth, Money> otheri = CalculateAverageNetworkFeePaidByUserPerCoinjoin(ScannerFiles.OtherCoinJoins); IDictionary <YearMonth, Money> wasabi = CalculateAverageNetworkFeePaidByUserPerCoinjoin(ScannerFiles.WasabiCoinJoins); IDictionary <YearMonth, Money> samuri = CalculateAverageNetworkFeePaidByUserPerCoinjoin(ScannerFiles.SamouraiCoinJoins); Display.DisplayOtheriWasabiSamuriResults(otheri, wasabi, samuri); } }
public void CalculateNeverMixed() { using (BenchmarkLogger.Measure()) { Dictionary <YearMonth, Money> otheri = CalculateNeverMixed(ScannerFiles.OtherCoinJoins); Dictionary <YearMonth, Money> wasabi = CalculateNeverMixed(ScannerFiles.WasabiCoinJoins); Dictionary <YearMonth, Money> samuri = CalculateNeverMixedFromTx0s(ScannerFiles.SamouraiCoinJoins, ScannerFiles.SamouraiTx0s); DisplayOtheriWasabiSamuriResults(otheri, wasabi, samuri); } }
public void CalculateMonthlyEqualVolumes() { using (BenchmarkLogger.Measure()) { Dictionary <YearMonth, Money> otheri = CalculateMonthlyEqualVolumes(ScannerFiles.OtherCoinJoins); Dictionary <YearMonth, Money> wasabi = CalculateMonthlyEqualVolumes(ScannerFiles.WasabiCoinJoins); Dictionary <YearMonth, Money> samuri = CalculateMonthlyEqualVolumes(ScannerFiles.SamouraiCoinJoins); Display.DisplayOtheriWasabiSamuriResults(otheri, wasabi, samuri); } }
public void CalculateFreshBitcoinsDaily() { using (BenchmarkLogger.Measure()) { Dictionary <YearMonthDay, Money> otheri = CalculateFreshBitcoinsDaily(ScannerFiles.OtherCoinJoins); Dictionary <YearMonthDay, Money> wasabi = CalculateFreshBitcoinsDaily(ScannerFiles.WasabiCoinJoins); Dictionary <YearMonthDay, Money> samuri = CalculateFreshBitcoinsDailyFromTX0s(ScannerFiles.SamouraiTx0s, ScannerFiles.SamouraiCoinJoinHashes); DisplayOtheriWasabiSamuriResults(otheri, wasabi, samuri); } }
public void CalculateMonthlyAverageMonthlyUserCounts() { using (BenchmarkLogger.Measure()) { IDictionary <YearMonth, int> otheri = CalculateAverageUserCounts(ScannerFiles.OtherCoinJoins); IDictionary <YearMonth, int> wasabi = CalculateAverageUserCounts(ScannerFiles.WasabiCoinJoins); IDictionary <YearMonth, int> samuri = CalculateAverageUserCounts(ScannerFiles.SamouraiCoinJoins); Display.DisplayOtheriWasabiSamuriResults(otheri, wasabi, samuri); } }
public FileSystemBlockRepository(string blocksFolderPath, Network network, long targetBlocksFolderSizeMb = 300) { using (BenchmarkLogger.Measure()) { BlocksFolderPath = blocksFolderPath; Network = network; CreateFolders(); EnsureBackwardsCompatibility(); Prune(targetBlocksFolderSizeMb); } }
public WalletManager(Network network, WalletDirectories walletDirectories) { using (BenchmarkLogger.Measure()) { Network = Guard.NotNull(nameof(network), network); WalletDirectories = Guard.NotNull(nameof(walletDirectories), walletDirectories); Wallets = new Dictionary <Wallet, HashSet <uint256> >(); Lock = new object(); AddRemoveLock = new AsyncLock(); CancelAllInitialization = new CancellationTokenSource(); } }
public WalletManager(Network network, string workDir, WalletDirectories walletDirectories) { using (BenchmarkLogger.Measure()) { Network = Guard.NotNull(nameof(network), network); WorkDir = Guard.NotNullOrEmptyOrWhitespace(nameof(workDir), workDir, true); Directory.CreateDirectory(WorkDir); WalletDirectories = Guard.NotNull(nameof(walletDirectories), walletDirectories); RefreshWalletList(); } }
private void CheckDuplication() { using (BenchmarkLogger.Measure()) { CheckDuplications(ScannerFiles.WasabiCoinJoinHashes, nameof(ScannerFiles.WasabiCoinJoins)); CheckDuplications(ScannerFiles.SamouraiCoinJoinHashes, nameof(ScannerFiles.SamouraiCoinJoins)); CheckDuplications(ScannerFiles.OtherCoinJoinHashes, nameof(ScannerFiles.OtherCoinJoins)); CheckDuplications(ScannerFiles.SamouraiTx0Hashes, nameof(ScannerFiles.SamouraiTx0s)); CheckDuplications(ScannerFiles.WasabiPostMixTxHashes, nameof(ScannerFiles.WasabiPostMixTxs)); CheckDuplications(ScannerFiles.SamouraiPostMixTxHashes, nameof(ScannerFiles.SamouraiPostMixTxs)); CheckDuplications(ScannerFiles.OtherCoinJoinPostMixTxHashes, nameof(ScannerFiles.OtherCoinJoinPostMixTxs)); } }
public async Task InitializeAsync(CancellationToken cancel = default) { using (BenchmarkLogger.Measure()) { var initTasks = new[] { IndexStore.InitializeAsync(cancel), TransactionStore.InitializeAsync(cancel: cancel) }; await Task.WhenAll(initTasks).ConfigureAwait(false); IsInitialized = true; } }
public async Task InitializeAsync() { using (BenchmarkLogger.Measure()) { var initTasks = new[] { IndexStore.InitializeAsync(), TransactionStore.InitializeAsync() }; await Task.WhenAll(initTasks).ConfigureAwait(false); IsInitialized = true; } }
public WalletManager(Network network, string workDir, WalletDirectories walletDirectories) { using (BenchmarkLogger.Measure()) { Network = Guard.NotNull(nameof(network), network); WorkDir = Guard.NotNullOrEmptyOrWhitespace(nameof(workDir), workDir, true); Directory.CreateDirectory(WorkDir); WalletDirectories = Guard.NotNull(nameof(walletDirectories), walletDirectories); Wallets = new Dictionary <Wallet, HashSet <uint256> >(); Lock = new object(); StartStopWalletLock = new AsyncLock(); CancelAllInitialization = new CancellationTokenSource(); RefreshWalletList(); } }
public async Task InitializeAsync(string workFolderPath, Network network) { using (BenchmarkLogger.Measure()) { WorkFolderPath = Guard.NotNullOrEmptyOrWhitespace(nameof(workFolderPath), workFolderPath, trim: true); IoHelpers.EnsureDirectoryExists(WorkFolderPath); Network = Guard.NotNull(nameof(network), network); IndexStore = new IndexStore(); var indexStoreFolderPath = Path.Combine(WorkFolderPath, Network.ToString(), "IndexStore"); HashChain = new HashChain(); MempoolService = new MempoolService(); await IndexStore.InitializeAsync(indexStoreFolderPath, Network, HashChain).ConfigureAwait(false); } }
public async Task InitializeAsync() { using (BenchmarkLogger.Measure()) { var networkWorkFolderPath = Path.Combine(WorkFolderPath, Network.ToString()); var indexStoreFolderPath = Path.Combine(networkWorkFolderPath, "IndexStore"); var initTasks = new[] { IndexStore.InitializeAsync(indexStoreFolderPath), TransactionStore.InitializeAsync(networkWorkFolderPath, Network) }; await Task.WhenAll(initTasks).ConfigureAwait(false); IsInitialized = true; } }