Ejemplo n.º 1
0
 internal string GetLocationUrl(AlgorithmType algorithmType, NhmConectionType conectionType)
 {
     if (StratumEndpointTemplatesByAlgorithmType.ContainsKey(algorithmType))
     {
         var customEndpointTemplateEntry = StratumEndpointTemplatesByAlgorithmType[algorithmType];
         return(GetCustomUrl(customEndpointTemplateEntry, conectionType));
     }
     return("");
 }
Ejemplo n.º 2
0
        private static (string prefix, int port) GetProtocolPrefixAndPort(NhmConectionType conectionType)
        {
            int port = conectionType == NhmConectionType.STRATUM_SSL ? 443 : 9200;

            return(conectionType switch
            {
                NhmConectionType.STRATUM_TCP => ("stratum+tcp://", port),
                NhmConectionType.STRATUM_SSL => ("stratum+ssl://", port),
                _ => ("", port),
            });
        public static string GetLocationUrl(AlgorithmType algorithmType, string miningLocation, NhmConectionType conectionType)
        {
            var name = GetAlgorithmUrlName(algorithmType);

            // if name is empty return
            if (name == "")
            {
                return("");
            }

            var nPort   = 3333 + algorithmType;
            var sslPort = 30000 + nPort;

            // NHMConectionType.NONE
            var prefix = "";
            var port   = nPort;

            switch (conectionType)
            {
            case NhmConectionType.LOCKED:
                return(miningLocation);

            case NhmConectionType.STRATUM_TCP:
                prefix = "stratum+tcp://";
                break;

            case NhmConectionType.STRATUM_SSL:
                prefix = "stratum+ssl://";
                port   = sslPort;
                break;
            }

#if CUSTOM_ENDPOINTS
            var customEndpointTemplateEntry = _stratumEndpointTemplatesByAlgorithmType[algorithmType];
            var customPort = customEndpointTemplateEntry.Port;
            if (conectionType == NhmConectionType.STRATUM_SSL)
            {
                customPort = customPort + 30000;
            }
            var customEndpointTemplate = customEndpointTemplateEntry.Template;
            customEndpointTemplate = customEndpointTemplate.Replace(PREFIX_TEMPLATE, prefix);
            customEndpointTemplate = customEndpointTemplate.Replace(LOCATION_TEMPLATE, miningLocation);
            customEndpointTemplate = customEndpointTemplate.Replace(PORT_TEMPLATE, $":{customPort}");
            return(customEndpointTemplate);
#elif TESTNET
            return(prefix
                   + name
                   + "-test." + miningLocation
                   + ".nicehash.com:"
                   + port);
#elif TESTNETDEV
            return(prefix
                   + "stratum-test." + miningLocation
                   + ".nicehash.com:"
                   + port);
#else
            return(prefix
                   + name
                   + "." + miningLocation
                   + ".nicehash.com:"
                   + port);
#endif
        }
Ejemplo n.º 4
0
        public static string GetLocationUrl(AlgorithmType algorithmType, string miningLocation, NhmConectionType conectionType)
        {
            var name = GetAlgorithmUrlName(algorithmType);

            // if name is empty return
            if (name == "")
            {
                return("");
            }

            var nPort   = 3333 + algorithmType;
            var sslPort = 30000 + nPort;

            // NHMConectionType.NONE
            var prefix = "";
            var port   = nPort;

            switch (conectionType)
            {
            case NhmConectionType.LOCKED:
                return(miningLocation);

            case NhmConectionType.STRATUM_TCP:
                prefix = "stratum+tcp://";
                break;

            case NhmConectionType.STRATUM_SSL:
                prefix = "stratum+ssl://";
                port   = sslPort;
                break;
            }

#if TESTNET
            return(prefix
                   + name
                   + "-test." + miningLocation
                   + ".nicehash.com:"
                   + port);
#elif TESTNETDEV
            return(prefix
                   + "stratum-test." + miningLocation
                   + ".nicehash.com:"
                   + port);
#else
            return(prefix
                   + name
                   + "." + miningLocation
                   + ".nicehash.com:"
                   + port);
#endif
        }
Ejemplo n.º 5
0
        public static string GetLocationUrl(AlgorithmType algorithmType, string miningLocation, NhmConectionType conectionType)
        {
            if (!NHSmaData.TryGetSma(algorithmType, out var sma))
            {
                return("");
            }

            var name    = sma.Name;
            var nPort   = sma.Port;
            var sslPort = 30000 + nPort;

            // NHMConectionType.NONE
            var prefix = "";
            var port   = nPort;

            switch (conectionType)
            {
            case NhmConectionType.LOCKED:
                return(miningLocation);

            case NhmConectionType.STRATUM_TCP:
                prefix = "stratum+tcp://";
                break;

            case NhmConectionType.STRATUM_SSL:
                prefix = "stratum+ssl://";
                port   = sslPort;
                break;
            }

            return(prefix
                   + name
                   + "." + miningLocation
                   + ".nicehash.com:"
                   + port);
        }
Ejemplo n.º 6
0
        public static string GetLocationUrl(AlgorithmType algorithmType, string miningLocation, NhmConectionType conectionType)
        {
            var(name, ok) = GetAlgorithmUrlName(algorithmType);
            // if name is not ok return
            if (!ok)
            {
                return("");
            }

            var nPort   = 3333 + algorithmType;
            var sslPort = 30000 + nPort;

            // NHMConectionType.NONE
            var prefix = "";
            var port   = nPort;

            switch (conectionType)
            {
            case NhmConectionType.LOCKED:
                return(miningLocation);

            case NhmConectionType.STRATUM_TCP:
                prefix = "stratum+tcp://";
                break;

            case NhmConectionType.STRATUM_SSL:
                prefix = "stratum+ssl://";
                port   = sslPort;
                break;
            }
            if (BuildOptions.CUSTOM_ENDPOINTS_ENABLED)
            {
                var customEndpointTemplateEntry = _stratumEndpointTemplatesByAlgorithmType[algorithmType];
                var customPort = customEndpointTemplateEntry.Port;
                if (conectionType == NhmConectionType.STRATUM_SSL)
                {
                    customPort = customPort + 30000;
                }
                var customEndpointTemplate = customEndpointTemplateEntry.Template;
                customEndpointTemplate = customEndpointTemplate.Replace(PREFIX_TEMPLATE, prefix);
                customEndpointTemplate = customEndpointTemplate.Replace(LOCATION_TEMPLATE, miningLocation);
                customEndpointTemplate = customEndpointTemplate.Replace(PORT_TEMPLATE, $":{customPort}");
                return(customEndpointTemplate);
            }
            if (BuildOptions.BUILD_TAG == BuildTag.TESTNET)
            {
                return(prefix
                       + name
                       + "-test." + miningLocation
                       + ".nicehash.com:"
                       + port);
            }
            if (BuildOptions.BUILD_TAG == BuildTag.TESTNETDEV)
            {
                return(prefix
                       + "stratum-test." + miningLocation
                       + ".nicehash.com:"
                       + port);
            }
            //BuildTag.PRODUCTION
            return(prefix
                   + name
                   + "." + miningLocation
                   + ".nicehash.com:"
                   + port);
        }
Ejemplo n.º 7
0
        public static string GetLocationUrl(AlgorithmType algorithmType, string miningLocation, NhmConectionType conectionType)
        {
            if (NiceHashData == null || !NiceHashData.ContainsKey(algorithmType))
            {
                return("");
            }

            var name    = NiceHashData[algorithmType].name;
            var nPort   = NiceHashData[algorithmType].port;
            var sslPort = 30000 + nPort;

            // NHMConectionType.NONE
            var prefix = "";
            var port   = nPort;

            switch (conectionType)
            {
            case NhmConectionType.LOCKED:
                return(miningLocation);

            case NhmConectionType.STRATUM_TCP:
                prefix = "stratum+tcp://";
                break;

            case NhmConectionType.STRATUM_SSL:
                prefix = "stratum+ssl://";
                port   = sslPort;
                break;
            }

            return(prefix
                   + name
                   + "." + miningLocation
                   + ".nicehash.com:"
                   + port);
        }
Ejemplo n.º 8
0
            private static string GetCustomUrl(StratumTemplateEntry customEndpointTemplateEntry, NhmConectionType conectionType)
            {
                var(prefix, _) = GetProtocolPrefixAndPort(conectionType);
                var customPort = customEndpointTemplateEntry.Port;

                var customEndpointTemplate = customEndpointTemplateEntry.Template
                                             .Replace(PREFIX_TEMPLATE, prefix)
                                             .Replace(PORT_TEMPLATE, $":{customPort}");

                return(customEndpointTemplate);
            }