static void Main(string[] args) { ErgoClient client = new ErgoClient(); client.Connect("localhost", 5678); Console.ReadKey(); client.Disconnect(); }
public virtual async Task ConfigureAsync(ClusterConfig cc, PoolConfig pc, CancellationToken ct) { Contract.RequiresNonNull(pc); logger = LogUtil.GetPoolScopedLogger(typeof(ErgoPayoutHandler), pc); poolConfig = pc; clusterConfig = cc; extraPoolPaymentProcessingConfig = pc.PaymentProcessing.Extra.SafeExtensionDataAs <ErgoPaymentProcessingConfigExtra>(); ergoClient = ErgoClientFactory.CreateClient(pc, cc, null); // detect chain var info = await ergoClient.GetNodeInfoAsync(ct); network = ErgoConstants.RegexChain.Match(info.Name).Groups[1].Value.ToLower(); }
public static ErgoClient CreateClient(PoolConfig poolConfig, ClusterConfig clusterConfig, ILogger logger) { var epConfig = poolConfig.Daemons.First(); var extra = epConfig.Extra.SafeExtensionDataAs <ErgoDaemonEndpointConfigExtra>(); if (logger != null && clusterConfig.PaymentProcessing?.Enabled == true && poolConfig.PaymentProcessing?.Enabled == true && string.IsNullOrEmpty(extra?.ApiKey)) { throw new PoolStartupException("Ergo daemon apiKey not provided", poolConfig.Id); } var baseUrl = new UriBuilder(epConfig.Ssl || epConfig.Http2 ? Uri.UriSchemeHttps : Uri.UriSchemeHttp, epConfig.Host, epConfig.Port, epConfig.HttpPath); var result = new ErgoClient(baseUrl.ToString(), new HttpClient(new HttpClientHandler { AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip, ServerCertificateCustomValidationCallback = (message, cert, chain, errors) => true, })); if (!string.IsNullOrEmpty(extra?.ApiKey)) { result.RequestHeaders["api_key"] = extra.ApiKey; } if (!string.IsNullOrEmpty(epConfig.User)) { var auth = $"{epConfig.User}:{epConfig.Password}"; result.RequestHeaders["Authorization"] = new AuthenticationHeaderValue("Basic", auth.ToByteArrayBase64()).ToString(); } #if DEBUG result.ReadResponseAsString = true; #endif return(result); }