Exemple #1
0
        private static (string templateStr, bool oldTemplate) CmdJSONString(string pluginUUID, string miningLocation, string username, params string[] uuids)
        {
            var templatePath          = CmdConfig.CommandFileTemplatePath(pluginUUID);
            var miningServiceLocation = GetServiceLocation(miningLocation);
            var str = CmdConfig.CreateCommandFileWithTemplate(miningServiceLocation, username, uuids, templatePath);

            if (str != null)
            {
                return(str, false);
            }
            const string DEVICE         = @"		{""id"":3,""method"":""worker.add"",""params"":[""daggerhashimoto"",""_DEV_ID_""]}";
            const string TEMPLATE       = @"
[
	{""time"":0,""commands"":[
		{""id"":1,""method"":""subscribe"",""params"":[""_MINING_SERVICE_LOCATION_"",""_PUT_YOUR_BTC_HERE_""]}
	]},
	{""time"":1,""commands"":[
        {""id"":1,""method"":""algorithm.add"",""params"":[""daggerhashimoto""]}
    ]},
	{""time"":2,""commands"":[
_DEVICES_
	]}
]";
            var          devices        = string.Join(",\n", uuids.Select(uuid => DEVICE.Replace("_DEV_ID_", uuid)));
            var          oldTemplateStr = TEMPLATE
                                          .Replace("_MINING_SERVICE_LOCATION_", miningServiceLocation)
                                          .Replace("_PUT_YOUR_BTC_HERE_", username)
                                          .Replace("_DEVICES_", devices);

            return(oldTemplateStr, true);
        }
 private void CreateExcavatorCommandTemplate(IEnumerable <string> uuids)
 {
     try
     {
         var templatePath = CmdConfig.CommandFileTemplatePath(PluginUUID);
         var template     = CmdConfig.CreateTemplate(uuids);
         if (!File.Exists(templatePath) && template != null)
         {
             File.WriteAllText(templatePath, template);
         }
     }
     catch (Exception e)
     {
         Logger.Error("ExcavatorPlugin", $"CreateExcavatorCommandTemplate {e}");
     }
 }
Exemple #3
0
        public override Dictionary <BaseDevice, IReadOnlyList <Algorithm> > GetSupportedAlgorithms(IEnumerable <BaseDevice> devices)
        {
            // SM 6.0+
            var cudaGpus   = devices.Where(dev => dev is CUDADevice cuda && cuda.SM_major >= 6).Cast <CUDADevice>();
            var supported  = new Dictionary <BaseDevice, IReadOnlyList <Algorithm> >();
            var minDrivers = new Version(411, 0); // TODO

            if (CUDADevice.INSTALLED_NVIDIA_DRIVERS < minDrivers)
            {
                return(supported);
            }

            foreach (var gpu in cudaGpus)
            {
                var algos = GetSupportedAlgorithmsForDevice(gpu);
                if (algos.Count > 0)
                {
                    supported.Add(gpu, algos);
                }
            }
            try
            {
                var templatePath = CmdConfig.CommandFileTemplatePath(PluginUUID);
                var template     = CmdConfig.CreateTemplate(supported.Select(p => p.Key.UUID));
                if (!File.Exists(templatePath) && template != null)
                {
                    File.WriteAllText(templatePath, template);
                }
            }
            catch (Exception e)
            {
                Logger.Error("ExcavatorPlugin", $"GetSupportedAlgorithms create cmd template {e}");
            }

            return(supported);
        }