public EsentStorageModule(string baseDirectory, ChainType rulesType, long?cacheSizeMinBytes = null, long?cacheSizeMaxBytes = null, string[] blockTxesStorageLocations = null) { this.baseDirectory = baseDirectory; this.blockTxesStorageLocations = blockTxesStorageLocations; this.dataDirectory = Path.Combine(baseDirectory, "Data", rulesType.ToString()); this.peersDirectory = Path.Combine(baseDirectory, "Peers", rulesType.ToString()); this.chainType = rulesType; this.cacheSizeMinBytes = cacheSizeMinBytes; this.cacheSizeMaxBytes = cacheSizeMaxBytes; }
public EsentStorageModule(string baseDirectory, ChainType rulesType, long? cacheSizeMinBytes = null, long? cacheSizeMaxBytes = null, string[] blockTxesStorageLocations = null) { this.baseDirectory = baseDirectory; this.blockTxesStorageLocations = blockTxesStorageLocations; this.dataDirectory = Path.Combine(baseDirectory, "Data", rulesType.ToString()); this.peersDirectory = Path.Combine(baseDirectory, "Peers", rulesType.ToString()); this.chainType = rulesType; this.cacheSizeMinBytes = cacheSizeMinBytes; this.cacheSizeMaxBytes = cacheSizeMaxBytes; }
public Task <Download <SliceDownloadData> > DownloadTransactionSlice(Storage storage, ChainType chainType, int chainId, uint chainIndex, long sliceId) { var chainTypeName = chainType.ToString().ToLower(); return(DownloadSlice(storage, $"static/{chainTypeName}chain/{chainId}/{chainIndex}/block/slice/{sliceId}/data/result.data", $"static/{chainTypeName}chain/{chainId}/{chainIndex}/block/slice/{sliceId}/header/result.data", $"static/{chainTypeName}chain/{chainId}/{chainIndex}/block/slice/{sliceId}/checksums/result.data", (checksumStream, headerStream, dataStream) => new TransactionSliceDownloadData(chainType, chainId, chainIndex, sliceId, storage, checksumStream, headerStream, dataStream))); }
public void LoadArgs(IConfiguration conf) { ChainType = DefaultConfiguration.GetChainType(conf); var defaultSettings = BTCPayDefaultSettings.GetDefaultSettings(ChainType); DataDir = conf.GetOrDefault <string>("datadir", defaultSettings.DefaultDataDirectory); Logs.Configuration.LogInformation("Network: " + ChainType.ToString()); var supportedChains = conf.GetOrDefault <string>("chains", "btc") .Split(',', StringSplitOptions.RemoveEmptyEntries) .Select(t => t.ToUpperInvariant()); NetworkProvider = new BTCPayNetworkProvider(ChainType).Filter(supportedChains.ToArray()); foreach (var chain in supportedChains) { if (NetworkProvider.GetNetwork(chain) == null) { throw new ConfigException($"Invalid chains \"{chain}\""); } } var validChains = new List <string>(); foreach (var net in NetworkProvider.GetAll()) { NBXplorerConnectionSetting setting = new NBXplorerConnectionSetting(); setting.CryptoCode = net.CryptoCode; setting.ExplorerUri = conf.GetOrDefault <Uri>($"{net.CryptoCode}.explorer.url", net.NBXplorerNetwork.DefaultSettings.DefaultUrl); setting.CookieFile = conf.GetOrDefault <string>($"{net.CryptoCode}.explorer.cookiefile", net.NBXplorerNetwork.DefaultSettings.DefaultCookieFile); NBXplorerConnectionSettings.Add(setting); var lightning = conf.GetOrDefault <string>($"{net.CryptoCode}.lightning", string.Empty); if (lightning.Length != 0) { if (!LightningConnectionString.TryParse(lightning, out var connectionString, out var error)) { throw new ConfigException($"Invalid setting {net.CryptoCode}.lightning, you need to pass either " + $"the absolute path to the unix socket of a running CLightning instance (eg. /root/.lightning/lightning-rpc), " + $"or the url to a charge server with crendetials (eg. https://apitoken@API_TOKEN_SECRET:charge.example.com/)"); } InternalLightningByCryptoCode.Add(net.CryptoCode, connectionString); } } Logs.Configuration.LogInformation("Supported chains: " + String.Join(',', supportedChains.ToArray())); PostgresConnectionString = conf.GetOrDefault <string>("postgres", null); BundleJsCss = conf.GetOrDefault <bool>("bundlejscss", true); ExternalUrl = conf.GetOrDefault <Uri>("externalurl", null); var old = conf.GetOrDefault <Uri>("internallightningnode", null); if (old != null) { throw new ConfigException($"internallightningnode should not be used anymore, use btclightning instead"); } }
public LevelDbStorageModule(string baseDirectory, ChainType rulesType, ulong? blocksCacheSize = null, ulong? blocksWriteCacheSize = null, ulong? blockTxesCacheSize = null, ulong? blockTxesWriteCacheSize = null, ulong? chainStateCacheSize = null, ulong? chainStateWriteCacheSize = null, string[] blockTxesStorageLocations = null) { this.baseDirectory = baseDirectory; this.blockTxesStorageLocations = blockTxesStorageLocations; dataDirectory = Path.Combine(baseDirectory, "Data", rulesType.ToString()); peersDirectory = Path.Combine(baseDirectory, "Peers", rulesType.ToString()); chainType = rulesType; this.blocksCacheSize = blocksCacheSize; this.blocksWriteCacheSize = blocksWriteCacheSize; this.blockTxesCacheSize = blockTxesCacheSize ?? (ulong)128.MEBIBYTE(); this.blockTxesWriteCacheSize = blockTxesWriteCacheSize ?? (ulong)32.MEBIBYTE(); this.chainStateCacheSize = chainStateCacheSize ?? (ulong)512.MEBIBYTE(); this.chainStateWriteCacheSize = chainStateWriteCacheSize ?? (ulong)128.MEBIBYTE(); }
public LevelDbStorageModule(string baseDirectory, ChainType rulesType, ulong?blocksCacheSize = null, ulong?blocksWriteCacheSize = null, ulong?blockTxesCacheSize = null, ulong?blockTxesWriteCacheSize = null, ulong?chainStateCacheSize = null, ulong?chainStateWriteCacheSize = null, string[] blockTxesStorageLocations = null) { this.baseDirectory = baseDirectory; this.blockTxesStorageLocations = blockTxesStorageLocations; dataDirectory = Path.Combine(baseDirectory, "Data", rulesType.ToString()); peersDirectory = Path.Combine(baseDirectory, "Peers", rulesType.ToString()); chainType = rulesType; this.blocksCacheSize = blocksCacheSize; this.blocksWriteCacheSize = blocksWriteCacheSize; this.blockTxesCacheSize = blockTxesCacheSize ?? (ulong)128.MEBIBYTE(); this.blockTxesWriteCacheSize = blockTxesWriteCacheSize ?? (ulong)32.MEBIBYTE(); this.chainStateCacheSize = chainStateCacheSize ?? (ulong)512.MEBIBYTE(); this.chainStateWriteCacheSize = chainStateWriteCacheSize ?? (ulong)128.MEBIBYTE(); }
public async Task <Download <BlockData> > DownloadBlockData(ChainType chainType, int chainId, uint chainIndex, long blockId) { try { var chainTypeName = chainType.ToString().ToLower(); var blockRawData = await DownloadBinary($"static/{chainTypeName}chain/{chainId}/{chainIndex}/block/{blockId}/blockdata/result.data"); return(new Download <BlockData>(BlockData.Restore(blockRawData))); } catch (Exception exception) { return(Download <BlockData> .HandleException(exception)); } }
public static Network ToNetwork(this ChainType chainType) { if (chainType == ChainType.Main) { return(Network.Main); } if (chainType == ChainType.Test) { return(Network.TestNet); } if (chainType == ChainType.Regtest) { return(Network.RegTest); } throw new NotSupportedException(chainType.ToString()); }
public int tambahProxyChain(ChainType chainType, string chainName, List <KeyValuePair <int, bool> > proxyIDList, int RedundancyTimeout = 30, bool RedundancyTryDirect = false) { this.proxyCount += 1; List <KeyValuePair <int, bool> > proxyPairs = new List <KeyValuePair <int, bool> >(); foreach (KeyValuePair <int, bool> proxyPair in proxyIDList) { proxyPairs.Add(new KeyValuePair <int, bool>(proxyPair.Key, proxyPair.Value)); } this.chainList.Add(new object[] { this.proxyCount.ToString(), // [0] ID Chain chainType.ToString(), // [1] Chain type chainName, // [2] Chain name proxyPairs, // [3] Proxies + status RedundancyTimeout, // [4] RedundancyTimeout RedundancyTryDirect // [5] RedundancyTryDirect }); return(this.proxyCount); }
public void LoadArgs(IConfiguration conf) { ChainType = DefaultConfiguration.GetChainType(conf); var defaultSettings = BTCPayDefaultSettings.GetDefaultSettings(ChainType); DataDir = conf.GetOrDefault <string>("datadir", defaultSettings.DefaultDataDirectory); Logs.Configuration.LogInformation("Network: " + ChainType.ToString()); var supportedChains = conf.GetOrDefault <string>("chains", "btc") .Split(',', StringSplitOptions.RemoveEmptyEntries) .Select(t => t.ToUpperInvariant()); NetworkProvider = new BTCPayNetworkProvider(ChainType).Filter(supportedChains.ToArray()); foreach (var chain in supportedChains) { if (NetworkProvider.GetNetwork(chain) == null) { throw new ConfigException($"Invalid chains \"{chain}\""); } } var validChains = new List <string>(); foreach (var net in NetworkProvider.GetAll()) { NBXplorerConnectionSetting setting = new NBXplorerConnectionSetting(); setting.CryptoCode = net.CryptoCode; setting.ExplorerUri = conf.GetOrDefault <Uri>($"{net.CryptoCode}.explorer.url", net.NBXplorerNetwork.DefaultSettings.DefaultUrl); setting.CookieFile = conf.GetOrDefault <string>($"{net.CryptoCode}.explorer.cookiefile", net.NBXplorerNetwork.DefaultSettings.DefaultCookieFile); NBXplorerConnectionSettings.Add(setting); } Logs.Configuration.LogInformation("Supported chains: " + String.Join(',', supportedChains.ToArray())); PostgresConnectionString = conf.GetOrDefault <string>("postgres", null); BundleJsCss = conf.GetOrDefault <bool>("bundlejscss", true); ExternalUrl = conf.GetOrDefault <Uri>("externalurl", null); InternalLightningNode = conf.GetOrDefault <Uri>("internallightningnode", null); }
public void LoadArgs(IConfiguration conf) { ChainType = DefaultConfiguration.GetChainType(conf); var defaultSettings = BTCPayDefaultSettings.GetDefaultSettings(ChainType); DataDir = conf.GetOrDefault <string>("datadir", defaultSettings.DefaultDataDirectory); Logs.Configuration.LogInformation("Network: " + ChainType.ToString()); var supportedChains = conf.GetOrDefault <string>("chains", "btc") .Split(',', StringSplitOptions.RemoveEmptyEntries) .Select(t => t.ToUpperInvariant()); var validChains = new List <string>(); foreach (var net in new BTCPayNetworkProvider(ChainType).GetAll()) { if (supportedChains.Contains(net.CryptoCode)) { validChains.Add(net.CryptoCode); NBXplorerConnectionSetting setting = new NBXplorerConnectionSetting(); setting.CryptoCode = net.CryptoCode; setting.ExplorerUri = conf.GetOrDefault <Uri>($"{net.CryptoCode}.explorer.url", net.NBXplorerNetwork.DefaultSettings.DefaultUrl); setting.CookieFile = conf.GetOrDefault <string>($"{net.CryptoCode}.explorer.cookiefile", net.NBXplorerNetwork.DefaultSettings.DefaultCookieFile); NBXplorerConnectionSettings.Add(setting); } } var invalidChains = String.Join(',', supportedChains.Where(s => !validChains.Contains(s)).ToArray()); if (!string.IsNullOrEmpty(invalidChains)) { throw new ConfigException($"Invalid chains {invalidChains}"); } Logs.Configuration.LogInformation("Supported chains: " + String.Join(',', supportedChains.ToArray())); PostgresConnectionString = conf.GetOrDefault <string>("postgres", null); ExternalUrl = conf.GetOrDefault <Uri>("externalurl", null); }
public static string GetChainTypeName(ChainType chainType) { return($"{chainType.ToString().ToLower()}chain"); }
public static string GetTransactionStoragePath(ChainType chainType, int chainId, uint chainIndex) { return($"chains/{chainType.ToString().ToLower()}/{chainId}_{chainIndex}/transactions/"); }
private void InitBitcoin(ChainType chainType) { Add(new NBXplorerNetwork() { CryptoCode = "BTC", MinRPCVersion = 150000, NBitcoinNetwork = chainType == ChainType.Main ? Network.Main : chainType == ChainType.Test ? Network.TestNet : chainType == ChainType.Regtest ? Network.RegTest : throw new NotSupportedException(chainType.ToString()), DefaultSettings = NBXplorerDefaultSettings.GetDefaultSettings(chainType) });
protected static string GetQuery(ChainType chainType, int chainId, uint chainIndex, ushort featureId, string action, string path) { return($"dynamic/{chainType.ToString().ToLower()}chain/{chainId}/{chainIndex}/feature/{featureId}/{action}/{path}/{FeatureQuery.FileName}"); }
public static string GetBlockStoragePath(ChainType chainType, int chainId, uint chainIndex) { return($"chains/{chainType.ToString().ToLower()}/{chainId}_{chainIndex}/blocks/"); }
public TransactionDownloadManager(Storage storage, ClientBase client, ChainType chainType, int chainId, uint chainIndex, TransactionDownloadManagerFlags flags) { ChainType = chainType; ChainId = chainId; ChainIndex = chainIndex; Client = client; Flags = flags; _storage = storage; _accountEntryStorage = new EntryStorage <DataAccountStorageEntry>(storage); _groupEntryStorage = new EntryStorage <GroupStorageEntry>(storage); _targetedTransactionStorage = new EntryStorage <TargetedChainTransactionStorageEntry>(storage); _transactionStorage = new Lazy <DiscStorage>(() => new DiscStorage(_storage, $"transactionsstorage_{chainType.ToString().ToLower()}_{chainId}_{chainIndex}", 64, 0, DiscStorageFlags.UnsortedDynamicIndex)); _attachementsStorage = new Lazy <DiscStorage>(() => new DiscStorage(_storage, $"attachementsstorage_{chainType.ToString().ToLower()}_{chainId}_{chainIndex}", 64, 0, DiscStorageFlags.UnsortedDynamicIndex)); _decryptedAttachementsStorage = new Lazy <DiscStorage>(() => new DiscStorage(_storage, $"decryptedattachementsstorage_{chainType.ToString().ToLower()}_{chainId}_{chainIndex}", 64, 0, DiscStorageFlags.UnsortedDynamicIndex)); _lastAccessedStorage = new Lazy <DiscStorage>(() => new DiscStorage(_storage, $"lastaccessed_{chainType.ToString().ToLower()}_{chainId}_{chainIndex}", 8, 0, DiscStorageFlags.UnsortedDynamicIndex)); }
private void InitLitecoin(ChainType chainType) { NBXplorer.Altcoins.Litecoin.Networks.EnsureRegistered(); Add(new NBXplorerNetwork() { CryptoCode = "LTC", MinRPCVersion = 140200, NBitcoinNetwork = chainType == ChainType.Main ? NBXplorer.Altcoins.Litecoin.Networks.Mainnet: chainType == ChainType.Test ? NBXplorer.Altcoins.Litecoin.Networks.Testnet : chainType == ChainType.Regtest ? NBXplorer.Altcoins.Litecoin.Networks.Regtest : throw new NotSupportedException(chainType.ToString()), DefaultSettings = NBXplorerDefaultSettings.GetDefaultSettings(chainType) });