static StratumServiceHelpers() { if (BuildOptions.CUSTOM_ENDPOINTS_ENABLED == false) { return; } var jsonSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore, Culture = CultureInfo.InvariantCulture }; const string customSettingsFile = "custom_endpoints_settings.json"; if (File.Exists(customSettingsFile)) { var customSettings = JsonConvert.DeserializeObject <ServiceCustomSettings>(File.ReadAllText(customSettingsFile), jsonSettings); if (customSettings != null) { NhmSocketAddress = customSettings.NhmSocketAddress; _stratumEndpointTemplatesByAlgorithmType = customSettings.StratumEndpointTemplatesByAlgorithmType; } } else { foreach (AlgorithmType algorithmType in Enum.GetValues(typeof(AlgorithmType))) { if (algorithmType < 0) { continue; } var nPort = 3333 + algorithmType; var name = GetAlgorithmUrlName(algorithmType).name; var endpointTemplate = $"{PREFIX_TEMPLATE}{name}.{LOCATION_TEMPLATE}.nicehash.com{PORT_TEMPLATE}"; _stratumEndpointTemplatesByAlgorithmType[algorithmType] = new StratumTemplateEntry { Template = endpointTemplate, Port = (int)nPort }; } // create defaults var defaultCustomSettings = new ServiceCustomSettings { NhmSocketAddress = Nhmws.BuildTagNhmSocketAddress(), StratumEndpointTemplatesByAlgorithmType = _stratumEndpointTemplatesByAlgorithmType, }; File.WriteAllText(customSettingsFile, JsonConvert.SerializeObject(defaultCustomSettings, Formatting.Indented)); } }
public static ServiceCustomSettings Defaults() { var ret = new ServiceCustomSettings { NhmSocketAddress = Nhmws.BuildTagNhmSocketAddress() }; foreach (AlgorithmType algorithmType in Enum.GetValues(typeof(AlgorithmType))) { if (algorithmType < 0) { continue; } var name = GetAlgorithmUrlName(algorithmType).name; // we get something like this "{PREFIX://}daggerhashimoto.{LOCATION}.nicehash.com{:PORT}" ret.StratumEndpointTemplatesByAlgorithmType[algorithmType] = new StratumTemplateEntry { Template = $"{PREFIX_TEMPLATE}{name}.{LOCATION_TEMPLATE}.nicehash.com{PORT_TEMPLATE}", Port = (int)(3333 + algorithmType) }; } return(ret); }
internal static void InitStratumServiceHelpers() { if (BuildOptions.CUSTOM_ENDPOINTS_ENABLED == false) { return; } (_serviceCustomSettings, _) = InternalConfigs.GetDefaultOrFileSettings(Paths.RootPath("custom_endpoints_settings.json"), ServiceCustomSettings.Defaults()); }