@@ -36,7 +36,13 @@ public void Run(MasterConfigurationModel configuration)
3636 continue ;
3737 }
3838
39- var configArgument = GetConfigurationArgument ( configuration . PathsConfiguration . ConfigTemplate , outputPools ) ;
39+ var currency = GetPoolCurrency ( outputPools ) ;
40+ if ( string . IsNullOrWhiteSpace ( currency ) )
41+ {
42+ Console . WriteLine ( @"Instance {0}.{1} does not contain valid currency. Make sure currency for all pools is set to the same value." , RunConfigurationModel . ActiveSolutionConfiguration , i ) ;
43+ continue ;
44+ }
45+
4046 var utilizedHardware = instances . Hardware . Select ( x => new UtilizedHardware
4147 {
4248 Hardware = configuration . Hardware . GetValue ( x ) ,
@@ -47,7 +53,10 @@ public void Run(MasterConfigurationModel configuration)
4753 var amdArgument = GetAmdArgument ( configuration . PathsConfiguration . AmdTemplate , configuration . AmdProfiles , utilizedHardware . Where ( x => x . Hardware . Type == "amd" ) . ToList ( ) ) ;
4854 var nvidiaArgument = GetNvidiaArgument ( configuration . PathsConfiguration . NvidiaTemplate , configuration . NvidiaProfiles , utilizedHardware . Where ( x => x . Hardware . Type == "nvidia" ) . ToList ( ) ) ;
4955
50- RunMiner ( $ "{ configArgument } { cpuArgument } { amdArgument } { nvidiaArgument } ") ;
56+ var configArgument = GetConfigurationArgument ( configuration . PathsConfiguration . ConfigTemplate ) ;
57+ var poolsArgument = GetPoolsArgument ( configuration . PathsConfiguration . PoolsTemplate , outputPools , currency ) ;
58+
59+ RunMiner ( $ "{ configArgument } { poolsArgument } { cpuArgument } { amdArgument } { nvidiaArgument } ") ;
5160 }
5261 }
5362
@@ -64,11 +73,19 @@ private static List<PrioritizedPoolEntry> GetOutputPools(IDictionary<string, Poo
6473 TlsFingerprint = x . TlsFingerprint ,
6574 WalletAddress = x . WalletAddress ,
6675 UseNiceHash = x . UseNiceHash ,
67- UseTls = x . UseTls
76+ UseTls = x . UseTls ,
77+ RigId = x . RigId ,
78+ Currency = x . Currency
6879 } )
6980 . ToList ( ) ;
7081 }
7182
83+ private static string GetPoolCurrency ( IEnumerable < PrioritizedPoolEntry > pools )
84+ {
85+ var currencies = pools . Select ( x => ( x . Currency ?? string . Empty ) . ToLower ( ) ) . Distinct ( ) . ToList ( ) ;
86+ return currencies . Count != 1 ? null : currencies . First ( ) ;
87+ }
88+
7289 private static void RunMiner ( string arguments )
7390 {
7491 var startInfo = new ProcessStartInfo ( Path . GetFullPath ( "xmr-stak.exe" ) , arguments )
@@ -81,14 +98,29 @@ private static void RunMiner(string arguments)
8198 Process . Start ( startInfo ) ;
8299 }
83100
84- private string GetConfigurationArgument ( string configurationTemplatePath , IReadOnlyCollection < PrioritizedPoolEntry > pools )
101+ private string GetConfigurationArgument ( string configurationTemplatePath )
85102 {
86- var configPath = CreateTemporaryConfiguration ( configurationTemplatePath , "config" , "%POOLS%" , pools ) ;
103+ var configPath = CreateTemporaryConfiguration ( configurationTemplatePath , "config" ) ;
87104 ScheduleFileDelete ( configPath ) ;
88105
89106 return $ "--config \" { configPath } \" ";
90107 }
91108
109+ private string GetPoolsArgument ( string poolsTemplatePath , IReadOnlyCollection < PrioritizedPoolEntry > pools , string currency )
110+ {
111+ foreach ( var prioritizedPoolEntry in pools )
112+ {
113+ prioritizedPoolEntry . Currency = null ;
114+ }
115+
116+ var configPath = CreateTemporaryConfiguration ( poolsTemplatePath , "pools" ,
117+ new VariableReplacement ( "%POOLS%" , pools ) ,
118+ new VariableReplacement ( "%CURRENCY%" , currency ) ) ;
119+ ScheduleFileDelete ( configPath ) ;
120+
121+ return $ "--poolconf \" { configPath } \" ";
122+ }
123+
92124 private string GetCpuArgument ( string cpuTemplatePath , IDictionary < string , IList < CpuThreadEntry > > cpuConfiguration , ICollection < UtilizedHardware > entry )
93125 {
94126 if ( entry . Count == 0 )
@@ -97,7 +129,7 @@ private string GetCpuArgument(string cpuTemplatePath, IDictionary<string, IList<
97129 }
98130
99131 var cpuProfile = entry . SelectMany ( x => cpuConfiguration . GetValue ( x . Profile ) ) . ToList ( ) ;
100- var path = CreateTemporaryConfiguration ( cpuTemplatePath , "cpu" , "%THREADS%" , cpuProfile ) ;
132+ var path = CreateTemporaryConfiguration ( cpuTemplatePath , "cpu" , new VariableReplacement ( "%THREADS%" , cpuProfile ) ) ;
101133 ScheduleFileDelete ( path ) ;
102134
103135 return $ "--cpu \" { path } \" ";
@@ -124,7 +156,7 @@ private string GetAmdArgument(string amdTemplatePath, IDictionary<string, IList<
124156 } ) )
125157 . ToList ( ) ;
126158
127- var path = CreateTemporaryConfiguration ( amdTemplatePath , "amd" , "%THREADS%" , amdProfile ) ;
159+ var path = CreateTemporaryConfiguration ( amdTemplatePath , "amd" , new VariableReplacement ( "%THREADS%" , amdProfile ) ) ;
128160 ScheduleFileDelete ( path ) ;
129161
130162 return $ "--amd \" { path } \" ";
@@ -153,21 +185,40 @@ private string GetNvidiaArgument(string nvidiaTemplatePath, IDictionary<string,
153185 } ) )
154186 . ToList ( ) ;
155187
156- var path = CreateTemporaryConfiguration ( nvidiaTemplatePath , "nvidia" , "%THREADS%" , nvidiaProfile ) ;
188+ var path = CreateTemporaryConfiguration ( nvidiaTemplatePath , "nvidia" , new VariableReplacement ( "%THREADS%" , nvidiaProfile ) ) ;
157189 ScheduleFileDelete ( path ) ;
158190
159191 return $ "--nvidia \" { path } \" ";
160192 }
161193
162- private static string CreateTemporaryConfiguration ( string templatePath , string type , string variable , object value )
194+ private static string CreateTemporaryConfiguration ( string templatePath , string type , params VariableReplacement [ ] variables )
163195 {
164- var configTemplateContent = File . ReadAllText ( templatePath ) ;
165- var configContent = configTemplateContent . Replace ( variable , JsonConvert . SerializeObject ( value , Formatting . Indented ) ) ;
196+ var content = File . ReadAllText ( templatePath ) ;
197+ if ( variables != null )
198+ {
199+ foreach ( var variable in variables )
200+ {
201+ content = content . Replace ( variable . Variable , JsonConvert . SerializeObject ( variable . Value , Formatting . Indented ) ) ;
202+ }
203+ }
204+
166205 var configPath = $ "{ Guid . NewGuid ( ) } .{ type } .txt";
167- File . WriteAllText ( configPath , configContent ) ;
206+ File . WriteAllText ( configPath , content ) ;
168207 return configPath ;
169208 }
170209
210+ private class VariableReplacement
211+ {
212+ public string Variable { get ; set ; }
213+ public object Value { get ; set ; }
214+
215+ public VariableReplacement ( string variable , object value )
216+ {
217+ Variable = variable ;
218+ Value = value ;
219+ }
220+ }
221+
171222 private void ScheduleFileDelete ( string file )
172223 {
173224 Finalizer . ScheduleFinalization ( ( ) =>
0 commit comments