@@ -70,6 +70,7 @@ static char doc[] = "Decentralized Alternative Templates for Universal Mining -
7070static char args_doc [] = "" ;
7171static struct argp_option options [] = {
7272 {"help" , '?' , 0 , 0 , "Show custom help" , 0 },
73+ {"example-conf" , 0x100 , NULL , 0 , "Print an example configuration JSON file" , 0 },
7374 {"usage" , '?' , 0 , 0 , "Show custom help" , 0 },
7475 {"config" , 'c' , "FILE" , 0 , "Configuration JSON file" },
7576 {0 }
@@ -83,14 +84,19 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
8384 struct arguments * arguments = state -> input ;
8485 switch (key ) {
8586 case '?' : {
86- datum_gateway_help ();
87+ datum_print_banner ();
88+ datum_gateway_help (state -> argv [0 ]);
8789 exit (0 );
8890 break ;
8991 }
9092 case 'c' : {
9193 arguments -> config_file = arg ;
9294 break ;
9395 }
96+ case 0x100 : // example-conf
97+ datum_gateway_example_conf ();
98+ exit (0 );
99+ break ;
94100 default :
95101 return ARGP_ERR_UNKNOWN ;
96102 }
@@ -100,6 +106,14 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
100106static struct argp argp = {options , parse_opt , args_doc , doc };
101107// END ARGP Stuff
102108
109+ void datum_print_banner (void ) {
110+ printf ("\n **************************************************************************\n" );
111+ printf (" * DATUM Gateway --- Copyright (c) 2024 Bitcoin Ocean, LLC & Jason Hughes *\n" );
112+ printf (" * git commit: %-58s *\n" , GIT_COMMIT_HASH );
113+ printf (" **************************************************************************\n\n" );
114+ fflush (stdout );
115+ }
116+
103117void handle_sigusr1 (int sig ) {
104118 datum_blocktemplates_notifynew (NULL , 0 );
105119}
@@ -119,19 +133,14 @@ int main(const int argc, const char * const * const argv) {
119133 bool rejecting_stratum = false;
120134 uint32_t next_reconnect_attempt_ms = 5000 ;
121135
122- printf ("\n **************************************************************************\n" );
123- printf (" * DATUM Gateway --- Copyright (c) 2024 Bitcoin Ocean, LLC & Jason Hughes *\n" );
124- printf (" * git commit: %-58s *\n" , GIT_COMMIT_HASH );
125- printf (" **************************************************************************\n\n" );
126- fflush (stdout );
127-
128136 // listen for block notifications
129137 // set this up early so a notification doesn't break our init
130138 sa .sa_handler = handle_sigusr1 ;
131139 sa .sa_flags = 0 ;
132140 sigemptyset (& sa .sa_mask );
133141
134142 if (sigaction (SIGUSR1 , & sa , NULL ) == -1 ) {
143+ datum_print_banner ();
135144 DLOG_FATAL ("Could not setup signal handler!" );
136145 perror ("sigaction" );
137146 usleep (100000 );
@@ -148,9 +157,11 @@ int main(const int argc, const char * const * const argv) {
148157
149158 arguments .config_file = "datum_gateway_config.json" ; // Default config file
150159 if (argp_parse (& argp , argc , datum_deepcopy_charpp (argv ), 0 , 0 , & arguments ) != 0 ) {
160+ datum_print_banner ();
151161 DLOG_FATAL ("Error parsing arguments. Check --help" );
152162 exit (1 );
153163 }
164+ datum_print_banner ();
154165
155166 if (datum_read_config (arguments .config_file ) != 1 ) {
156167 DLOG_FATAL ("Error reading config file. Check --help" );
0 commit comments