@@ -7,7 +7,7 @@ use crate::constants::{
77 POLYGON_MAINNET_FULL_IDENTIFIER ,
88} ;
99use crate :: crash_point:: CrashPoint ;
10- use clap:: { App , Arg } ;
10+ use clap:: { arg_enum , App , Arg } ;
1111use lazy_static:: lazy_static;
1212
1313pub const BLOCKCHAIN_SERVICE_HELP : & str =
@@ -81,6 +81,17 @@ pub const NEIGHBORS_HELP: &str = "One or more Node descriptors for running Nodes
8181 if you don't specify a neighbor, your Node will start without being connected to any MASQ \
8282 Network, although other Nodes will be able to connect to yours if they know your Node's descriptor. \
8383 --neighbors is meaningless in --neighborhood-mode zero-hop.";
84+ pub const NEW_PUBLIC_KEY_HELP : & str = "Whenever you start it, the Node will try to use the same public key \
85+ it used last time. That's '--new-public-key off'. If you want it to select a new public key when it \
86+ starts, then specify '--new-public-key on', and you'll get a different one this time...which it will \
87+ reuse next time unless you specify '--new-public-key on' again.\n \n \
88+ You should be careful about restarting your Node with the same public key too quickly. If your new \
89+ Node tries to join the Network before the Network has forgotten your old Node, every Node you try \
90+ to connect to will ignore you.\n \n \
91+ There are some conditions under which the Node cannot use the same public key it used last time: \
92+ for example, if there was no last time, or if you don't specify a `--db-password`. Normally, in \
93+ these situations, the Node will select a new public key and store it for future use; but if you \
94+ explicitly demand the old public key with `--new-public-key off`, the Node will refuse to start.";
8495
8596// generated valid encoded keys for future needs
8697// UJNoZW5p/PDVqEjpr3b+8jZ/93yPG8i5dOAgE1bhK+A
@@ -225,6 +236,14 @@ lazy_static! {
225236 DEFAULT_GAS_PRICE ) ;
226237}
227238
239+ arg_enum ! {
240+ #[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
241+ pub enum OnOff {
242+ On ,
243+ Off ,
244+ }
245+ }
246+
228247// These Args are needed in more than one clap schema. To avoid code duplication, they're defined here and referred
229248// to from multiple places.
230249pub fn chain_arg < ' a > ( ) -> Arg < ' a , ' a > {
@@ -466,13 +485,23 @@ pub fn shared_app(head: App<'static, 'static>) -> App<'static, 'static> {
466485 . min_values ( 0 )
467486 . help ( NEIGHBORS_HELP ) ,
468487 )
488+ . arg (
489+ Arg :: with_name ( "new-public-key" )
490+ . long ( "new-public-key" )
491+ . value_name ( "NEW-PUBLIC-KEY" )
492+ . takes_value ( true )
493+ . possible_values ( & OnOff :: variants ( ) )
494+ . case_insensitive ( true )
495+ . help ( NEW_PUBLIC_KEY_HELP ) ,
496+ )
469497 . arg ( real_user_arg ( ) )
470498 . arg (
471499 Arg :: with_name ( "scans" )
472500 . long ( "scans" )
473501 . value_name ( "SCANS" )
474502 . takes_value ( true )
475- . possible_values ( & [ "on" , "off" ] )
503+ . possible_values ( & OnOff :: variants ( ) )
504+ . case_insensitive ( true )
476505 . help ( SCANS_HELP ) ,
477506 )
478507 . arg ( common_parameter_with_separate_u64_values (
0 commit comments