@@ -195,7 +195,14 @@ inline void prompt_once(bool& prompted)
195195	}
196196}
197197
198- void  do_guided_pool_config (const  bool  use_simple_start)
198+ inline  bool  use_simple_start ()
199+ {
200+ 	//  ask this question only once
201+ 	static  bool  simple_start = read_yes_no (" \n Use simple setup method? (Y/n)"  , " Y"  );
202+ 	return  simple_start;
203+ }
204+ 
205+ void  do_guided_pool_config ()
199206{
200207	using  namespace  xmrstak ; 
201208
@@ -261,19 +268,22 @@ void do_guided_pool_config(const bool use_simple_start)
261268	}
262269
263270	auto & rigid = params::inst ().poolRigid ;
264- 	if (!use_simple_start &&  rigid.empty () && !params::inst ().userSetRigid )
271+ 	if (rigid.empty () && !params::inst ().userSetRigid )
265272	{
266- 		prompt_once (prompted);
267- 
268- 		if (!stdin_flushed)
273+ 		if (!use_simple_start ())
269274		{
270- 			//  clear everything from stdin to allow an empty rigid
271- 			std::cin.clear ();
272- 			std::cin.ignore (INT_MAX, ' \n '  );
273- 		}
275+ 			prompt_once (prompted);
274276
275- 		std::cout << " - Rig identifier for pool-side statistics (needs pool support). Can be empty:"   << std::endl;
276- 		getline (std::cin, rigid);
277+ 			if (!stdin_flushed)
278+ 			{
279+ 				//  clear everything from stdin to allow an empty rigid
280+ 				std::cin.clear ();
281+ 				std::cin.ignore (INT_MAX, ' \n '  );
282+ 			}
283+ 
284+ 			std::cout << " - Rig identifier for pool-side statistics (needs pool support). Can be empty:"   << std::endl;
285+ 			getline (std::cin, rigid);
286+ 		}
277287	}
278288
279289	bool  tls = params::inst ().poolUseTls ;
@@ -289,15 +299,19 @@ void do_guided_pool_config(const bool use_simple_start)
289299#endif 
290300
291301	bool  nicehash = params::inst ().nicehashMode ;
292- 	if (!use_simple_start && ! userSetPool)
302+ 	if (!userSetPool)
293303	{
294- 		prompt_once (prompted);
295- 		nicehash = read_yes_no (" - Do you want to use nicehash on this pool? (y/N)"  , " N"  );
304+ 		if (!use_simple_start ())
305+ 		{
306+ 			prompt_once (prompted);
307+ 			nicehash = read_yes_no (" - Do you want to use nicehash on this pool? (y/N)"  , " N"  );
308+ 		}
296309	}
297310
298311	bool  multipool = false ;
299- 	if (!use_simple_start && !userSetPool)
300- 		multipool = read_yes_no (" - Do you want to use multiple pools? (y/N)"  , " N"  );
312+ 	if (!userSetPool)
313+ 		if (!use_simple_start ())
314+ 			multipool = read_yes_no (" - Do you want to use multiple pools? (y/N)"  , " N"  );
301315
302316	int64_t  pool_weight = 1 ;
303317	if (multipool)
@@ -335,7 +349,7 @@ void do_guided_pool_config(const bool use_simple_start)
335349	std::cout << " Pool configuration stored in file '"   << params::inst ().configFilePools  << " '"   << std::endl;
336350}
337351
338- void  do_guided_config (const   bool  use_simple_start )
352+ void  do_guided_config ()
339353{
340354	using  namespace  xmrstak ; 
341355
@@ -353,7 +367,7 @@ void do_guided_config(const bool use_simple_start)
353367	{
354368		http_port = params::httpd_port_disabled;
355369#ifndef  CONF_NO_HTTPD
356- 		if (!use_simple_start)
370+ 		if (!use_simple_start () )
357371		{
358372			prompt_once (prompted);
359373
@@ -737,17 +751,13 @@ int main(int argc, char* argv[])
737751	bool  hasConfigFile = configEditor::file_exist (params::inst ().configFile );
738752	bool  hasPoolConfig = configEditor::file_exist (params::inst ().configFilePools );
739753
740- 	if (!hasConfigFile || !hasPoolConfig) 
741- 	{ 
742- 		bool  use_simple_start =  read_yes_no ( " \n Use simple setup method? (Y/n) " ,  " Y "  );
754+ 	//  check if we need a guided start 
755+ 	if (!hasConfigFile) 
756+ 		do_guided_config ( );
743757
744- 		//  check if we need a guided start
745- 		if (!hasConfigFile)
746- 			do_guided_config (use_simple_start);
758+ 	if (!hasPoolConfig)
759+ 		do_guided_pool_config ();
747760
748- 		if (!hasPoolConfig)
749- 			do_guided_pool_config (use_simple_start);
750- 	}
751761	if (!jconf::inst ()->parse_config (params::inst ().configFile .c_str (), params::inst ().configFilePools .c_str ()))
752762	{
753763		win_exit ();
0 commit comments