@@ -41,7 +41,7 @@ class CommandList
4141 ObjectCreationHandling = ObjectCreationHandling . Replace
4242 } ;
4343
44- public static string CreateTemplate ( IEnumerable < string > gpuUuids , string algorithmName )
44+ public static string CreateTemplate ( IEnumerable < int > gpuUuids , string algorithmName )
4545 {
4646 return CreateDefaultTemplateAndCreateCMD ( "__SUBSCRIBE_PARAM_LOCATION__" , "__SUBSCRIBE_PARAM_USERNAME__" , gpuUuids , algorithmName ) ;
4747 }
@@ -51,18 +51,22 @@ public static string CommandFileTemplatePath(string pluginUUID)
5151 return Paths . MinerPluginsPath ( pluginUUID , "internals" , "CommandLineTemplate.json" ) ;
5252 }
5353
54- private static List < Command > CreateInitialCommands ( string subscribeLocation , string subscribeUsername , IEnumerable < string > gpuUuids , string algorithmName )
54+ private static List < Command > CreateInitialCommands ( string subscribeLocation , string subscribeUsername , IEnumerable < int > excavatorIds , string algorithmName )
5555 {
5656 var initialCommands = new List < Command >
5757 {
5858 new Command { Id = 1 , Method = "subscribe" , Params = new List < string > { subscribeLocation , subscribeUsername } } ,
5959 new Command { Id = 2 , Method = "algorithm.add" , Params = new List < string > { algorithmName . ToLower ( ) } } ,
6060 } ;
61- initialCommands . AddRange ( gpuUuids . Select ( ( gpu , index ) => new Command { Id = index + 3 , Method = "worker.add" , Params = new List < string > { algorithmName . ToLower ( ) , gpu } } ) ) ;
61+ if ( algorithmName == "randomx" )
62+ {
63+ initialCommands . AddRange ( excavatorIds . Select ( ( dev , index ) => new Command { Id = index + 3 , Method = "worker.add" , Params = new List < string > { algorithmName , dev . ToString ( ) , "NTHREADS=0" , "HIGHPRIORITY=0" , "USELARGEPAGE=1" , "USEMSR=1" } } ) ) ;
64+ }
65+ else initialCommands . AddRange ( excavatorIds . Select ( ( dev , index ) => new Command { Id = index + 3 , Method = "worker.add" , Params = new List < string > { algorithmName . ToLower ( ) , dev . ToString ( ) } } ) ) ;
6266 return initialCommands ;
6367 }
6468
65- private static string CreateDefaultTemplateAndCreateCMD ( string subscribeLocation , string subscribeUsername , IEnumerable < string > gpuUuids , string algorithmName )
69+ private static string CreateDefaultTemplateAndCreateCMD ( string subscribeLocation , string subscribeUsername , IEnumerable < int > excavatorIds , string algorithmName )
6670 {
6771 try
6872 {
@@ -71,7 +75,7 @@ private static string CreateDefaultTemplateAndCreateCMD(string subscribeLocation
7175 new CommandList
7276 {
7377 Time = 0 ,
74- Commands = CreateInitialCommands ( subscribeLocation , subscribeUsername , gpuUuids , algorithmName ) ,
78+ Commands = CreateInitialCommands ( subscribeLocation , subscribeUsername , excavatorIds , algorithmName ) ,
7579 } ,
7680 new CommandList
7781 {
@@ -88,15 +92,15 @@ private static string CreateDefaultTemplateAndCreateCMD(string subscribeLocation
8892 }
8993 }
9094 private static string [ ] _invalidTemplateMethods = new string [ ] { "subscribe" , "algorithm.add" , "worker.add" } ;
91- private static string ParseTemplateFileAndCreateCMD ( string templateFilePath , IEnumerable < string > gpuUuids , string subscribeLocation , string subscribeUsername , string algorithmName )
95+ private static string ParseTemplateFileAndCreateCMD ( string templateFilePath , IEnumerable < int > excavatorIds , string subscribeLocation , string subscribeUsername , string algorithmName )
9296 {
9397 if ( ! File . Exists ( templateFilePath ) ) return null ;
9498 try
9599 {
96100 var template = JsonConvert . DeserializeObject < List < CommandList > > ( File . ReadAllText ( templateFilePath ) , _jsonSettings ) ;
97101 var validCmds = template
98102 . Where ( cmd => cmd . Commands . All ( c => ! _invalidTemplateMethods . Contains ( c . Method ) ) )
99- . Select ( cmd => ( cmd , commands : cmd . Commands . Where ( c => IsValidSessionCommand ( c , gpuUuids ) ) . ToList ( ) ) )
103+ . Select ( cmd => ( cmd , commands : cmd . Commands . ToList ( ) ) )
100104 . Where ( p => p . commands . Any ( ) )
101105 . ToArray ( ) ;
102106 foreach ( var ( cmd , commands ) in validCmds )
@@ -108,7 +112,7 @@ private static string ParseTemplateFileAndCreateCMD(string templateFilePath, IEn
108112 new CommandList
109113 {
110114 Time = 0 ,
111- Commands = CreateInitialCommands ( subscribeLocation , subscribeUsername , gpuUuids , algorithmName ) ,
115+ Commands = CreateInitialCommands ( subscribeLocation , subscribeUsername , excavatorIds , algorithmName ) ,
112116 } ,
113117 } ;
114118 if ( validCmds . Any ( ) ) commandListTemplate . AddRange ( validCmds . Select ( p => p . cmd ) ) ;
@@ -121,21 +125,13 @@ private static string ParseTemplateFileAndCreateCMD(string templateFilePath, IEn
121125 }
122126 }
123127
124- private static bool IsValidSessionCommand ( Command command , IEnumerable < string > gpuUuids )
125- {
126- var anyMissingGpuUuidParams = command . Params
127- . Where ( p => p . StartsWith ( "GPU" ) )
128- . Any ( pGpu => ! gpuUuids . Contains ( pGpu ) ) ;
129- return ! anyMissingGpuUuidParams ;
130- }
131-
132- private static string CreateCommandWithTemplate ( string subscribeLocation , string subscribeUsername , IEnumerable < string > gpuUuids , string templateFilePath , string algorithmName )
128+ private static string CreateCommandWithTemplate ( string subscribeLocation , string subscribeUsername , IEnumerable < int > excavatorIds , string templateFilePath , string algorithmName )
133129 {
134- var template = ParseTemplateFileAndCreateCMD ( templateFilePath , gpuUuids , subscribeLocation , subscribeUsername , algorithmName ) ;
130+ var template = ParseTemplateFileAndCreateCMD ( templateFilePath , excavatorIds , subscribeLocation , subscribeUsername , algorithmName ) ;
135131 if ( template == null )
136132 {
137133 Logger . Warn ( "Excavator.CmdConfig" , "Template file not found, using default!" ) ;
138- template = CreateDefaultTemplateAndCreateCMD ( subscribeLocation , subscribeUsername , gpuUuids , algorithmName ) ;
134+ template = CreateDefaultTemplateAndCreateCMD ( subscribeLocation , subscribeUsername , excavatorIds , algorithmName ) ;
139135 }
140136 return template ;
141137 }
@@ -147,11 +143,11 @@ private static string GetServiceLocation(string miningLocation)
147143 return $ "nhmp.auto.nicehash.com:443";
148144 }
149145
150- public static string CmdJSONString ( string pluginUUID , string _miningLocation , string username , string algorithmName , params string [ ] uuids ) {
146+ public static string CmdJSONString ( string pluginUUID , string _miningLocation , string username , string algorithmName , params int [ ] excavatorIds ) {
151147 var miningLocation = GetMiningLocation ( _miningLocation ) ;
152148 var templatePath = CommandFileTemplatePath ( pluginUUID ) ;
153149 var miningServiceLocation = GetServiceLocation ( miningLocation ) ;
154- var command = CreateCommandWithTemplate ( miningServiceLocation , username , uuids , templatePath , algorithmName ) ;
150+ var command = CreateCommandWithTemplate ( miningServiceLocation , username , excavatorIds , templatePath , algorithmName ) ;
155151 if ( command == null ) Logger . Error ( "Excavator.CmdConfig" , "command is NULL" ) ;
156152 return command ;
157153 }
0 commit comments