Skip to content

Commit 84ee6cc

Browse files
committed
v0.8.13: add --minfee=... command line option to control minimal transaction fee
1 parent ef88513 commit 84ee6cc

6 files changed

Lines changed: 81 additions & 42 deletions

File tree

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project( 'Warthog', ['c','cpp'],
2-
version : '0.8.12',
2+
version : '0.8.13',
33
default_options : ['warning_level=3', 'cpp_std=c++20'])
44

55
libuv_dep = subproject('libuv', default_options : ['warning_level=0', 'werror=false', 'build_tests=false']).get_variable('libuv_dep')

src/node/cmdline/cmdline.c

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ const char *gengetopt_args_info_detailed_help[] = {
4747
" This option starts the node with a temporary empty chain database.",
4848
" --testnet Enable testnet",
4949
" --disable-tx-mining Don't mine transactions (in case of bugs)",
50+
" --minfee=STRING Set minimal transaction fee accepted by this node,\n defaults to 0.01",
5051
"\nData file options:",
5152
" --chain-db=STRING specify chain data file",
5253
" Defaults to ~/.warthog/chain.db3 in Linux, %LOCALAPPDATA%/Warthog/chain.db3\n on Windows.'",
@@ -82,8 +83,8 @@ init_help_array(void)
8283
gengetopt_args_info_help[9] = gengetopt_args_info_detailed_help[12];
8384
gengetopt_args_info_help[10] = gengetopt_args_info_detailed_help[13];
8485
gengetopt_args_info_help[11] = gengetopt_args_info_detailed_help[14];
85-
gengetopt_args_info_help[12] = gengetopt_args_info_detailed_help[16];
86-
gengetopt_args_info_help[13] = gengetopt_args_info_detailed_help[18];
86+
gengetopt_args_info_help[12] = gengetopt_args_info_detailed_help[15];
87+
gengetopt_args_info_help[13] = gengetopt_args_info_detailed_help[17];
8788
gengetopt_args_info_help[14] = gengetopt_args_info_detailed_help[19];
8889
gengetopt_args_info_help[15] = gengetopt_args_info_detailed_help[20];
8990
gengetopt_args_info_help[16] = gengetopt_args_info_detailed_help[21];
@@ -94,11 +95,12 @@ init_help_array(void)
9495
gengetopt_args_info_help[21] = gengetopt_args_info_detailed_help[26];
9596
gengetopt_args_info_help[22] = gengetopt_args_info_detailed_help[27];
9697
gengetopt_args_info_help[23] = gengetopt_args_info_detailed_help[28];
97-
gengetopt_args_info_help[24] = 0;
98+
gengetopt_args_info_help[24] = gengetopt_args_info_detailed_help[29];
99+
gengetopt_args_info_help[25] = 0;
98100

99101
}
100102

101-
const char *gengetopt_args_info_help[25];
103+
const char *gengetopt_args_info_help[26];
102104

103105
typedef enum {ARG_NO
104106
, ARG_STRING
@@ -129,6 +131,7 @@ void clear_given (struct gengetopt_args_info *args_info)
129131
args_info->temporary_given = 0 ;
130132
args_info->testnet_given = 0 ;
131133
args_info->disable_tx_mining_given = 0 ;
134+
args_info->minfee_given = 0 ;
132135
args_info->chain_db_given = 0 ;
133136
args_info->peers_db_given = 0 ;
134137
args_info->debug_given = 0 ;
@@ -149,6 +152,8 @@ void clear_args (struct gengetopt_args_info *args_info)
149152
args_info->bind_orig = NULL;
150153
args_info->connect_arg = NULL;
151154
args_info->connect_orig = NULL;
155+
args_info->minfee_arg = NULL;
156+
args_info->minfee_orig = NULL;
152157
args_info->chain_db_arg = NULL;
153158
args_info->chain_db_orig = NULL;
154159
args_info->peers_db_arg = NULL;
@@ -178,16 +183,17 @@ void init_args_info(struct gengetopt_args_info *args_info)
178183
args_info->temporary_help = gengetopt_args_info_detailed_help[9] ;
179184
args_info->testnet_help = gengetopt_args_info_detailed_help[11] ;
180185
args_info->disable_tx_mining_help = gengetopt_args_info_detailed_help[12] ;
181-
args_info->chain_db_help = gengetopt_args_info_detailed_help[14] ;
182-
args_info->peers_db_help = gengetopt_args_info_detailed_help[16] ;
183-
args_info->debug_help = gengetopt_args_info_detailed_help[19] ;
184-
args_info->rpc_help = gengetopt_args_info_detailed_help[21] ;
185-
args_info->publicrpc_help = gengetopt_args_info_detailed_help[22] ;
186-
args_info->stratum_help = gengetopt_args_info_detailed_help[23] ;
187-
args_info->enable_public_help = gengetopt_args_info_detailed_help[24] ;
188-
args_info->config_help = gengetopt_args_info_detailed_help[26] ;
189-
args_info->test_help = gengetopt_args_info_detailed_help[27] ;
190-
args_info->dump_config_help = gengetopt_args_info_detailed_help[28] ;
186+
args_info->minfee_help = gengetopt_args_info_detailed_help[13] ;
187+
args_info->chain_db_help = gengetopt_args_info_detailed_help[15] ;
188+
args_info->peers_db_help = gengetopt_args_info_detailed_help[17] ;
189+
args_info->debug_help = gengetopt_args_info_detailed_help[20] ;
190+
args_info->rpc_help = gengetopt_args_info_detailed_help[22] ;
191+
args_info->publicrpc_help = gengetopt_args_info_detailed_help[23] ;
192+
args_info->stratum_help = gengetopt_args_info_detailed_help[24] ;
193+
args_info->enable_public_help = gengetopt_args_info_detailed_help[25] ;
194+
args_info->config_help = gengetopt_args_info_detailed_help[27] ;
195+
args_info->test_help = gengetopt_args_info_detailed_help[28] ;
196+
args_info->dump_config_help = gengetopt_args_info_detailed_help[29] ;
191197

192198
}
193199

@@ -290,6 +296,8 @@ cmdline_parser_release (struct gengetopt_args_info *args_info)
290296
free_string_field (&(args_info->bind_orig));
291297
free_string_field (&(args_info->connect_arg));
292298
free_string_field (&(args_info->connect_orig));
299+
free_string_field (&(args_info->minfee_arg));
300+
free_string_field (&(args_info->minfee_orig));
293301
free_string_field (&(args_info->chain_db_arg));
294302
free_string_field (&(args_info->chain_db_orig));
295303
free_string_field (&(args_info->peers_db_arg));
@@ -350,6 +358,8 @@ cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
350358
write_into_file(outfile, "testnet", 0, 0 );
351359
if (args_info->disable_tx_mining_given)
352360
write_into_file(outfile, "disable-tx-mining", 0, 0 );
361+
if (args_info->minfee_given)
362+
write_into_file(outfile, "minfee", args_info->minfee_orig, 0);
353363
if (args_info->chain_db_given)
354364
write_into_file(outfile, "chain-db", args_info->chain_db_orig, 0);
355365
if (args_info->peers_db_given)
@@ -622,6 +632,7 @@ cmdline_parser_internal (
622632
{ "temporary", 0, NULL, 0 },
623633
{ "testnet", 0, NULL, 0 },
624634
{ "disable-tx-mining", 0, NULL, 0 },
635+
{ "minfee", 1, NULL, 0 },
625636
{ "chain-db", 1, NULL, 0 },
626637
{ "peers-db", 1, NULL, 0 },
627638
{ "debug", 0, NULL, 'd' },
@@ -786,6 +797,20 @@ cmdline_parser_internal (
786797
additional_error))
787798
goto failure;
788799

800+
}
801+
/* Set minimal transaction fee accepted by this node, defaults to 0.01. */
802+
else if (strcmp (long_options[option_index].name, "minfee") == 0)
803+
{
804+
805+
806+
if (update_arg( (void *)&(args_info->minfee_arg),
807+
&(args_info->minfee_orig), &(args_info->minfee_given),
808+
&(local_args_info.minfee_given), optarg, 0, 0, ARG_STRING,
809+
check_ambiguity, override, 0, 0,
810+
"minfee", '-',
811+
additional_error))
812+
goto failure;
813+
789814
}
790815
/* specify chain data file. */
791816
else if (strcmp (long_options[option_index].name, "chain-db") == 0)

src/node/cmdline/cmdline.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ struct gengetopt_args_info
5050
const char *temporary_help; /**< @brief Use temporary database (for testing purposes, do not use in production) help description. */
5151
const char *testnet_help; /**< @brief Enable testnet help description. */
5252
const char *disable_tx_mining_help; /**< @brief Don't mine transactions (in case of bugs) help description. */
53+
char * minfee_arg; /**< @brief Set minimal transaction fee accepted by this node, defaults to 0.01. */
54+
char * minfee_orig; /**< @brief Set minimal transaction fee accepted by this node, defaults to 0.01 original value given at command line. */
55+
const char *minfee_help; /**< @brief Set minimal transaction fee accepted by this node, defaults to 0.01 help description. */
5356
char * chain_db_arg; /**< @brief specify chain data file. */
5457
char * chain_db_orig; /**< @brief specify chain data file original value given at command line. */
5558
const char *chain_db_help; /**< @brief specify chain data file help description. */
@@ -82,6 +85,7 @@ struct gengetopt_args_info
8285
unsigned int temporary_given ; /**< @brief Whether temporary was given. */
8386
unsigned int testnet_given ; /**< @brief Whether testnet was given. */
8487
unsigned int disable_tx_mining_given ; /**< @brief Whether disable-tx-mining was given. */
88+
unsigned int minfee_given ; /**< @brief Whether minfee was given. */
8589
unsigned int chain_db_given ; /**< @brief Whether chain-db was given. */
8690
unsigned int peers_db_given ; /**< @brief Whether peers-db was given. */
8791
unsigned int debug_given ; /**< @brief Whether debug was given. */

src/node/cmdline/cmdoptions.ggo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ option "isolated" - "Do not allow peers (for testing purposes, do not use in pro
1313
option "temporary" - "Use temporary database (for testing purposes, do not use in production)" details="This option starts the node with a temporary empty chain database." optional
1414
option "testnet" - "Enable testnet" optional
1515
option "disable-tx-mining" - "Don't mine transactions (in case of bugs)" optional
16+
option "minfee" - "Set minimal transaction fee accepted by this node, defaults to 0.01" optional string
1617

1718
section "Data file options"
1819
option "chain-db" - "specify chain data file" details="Defaults to ~/.warthog/chain.db3 in Linux, %LOCALAPPDATA%/Warthog/chain.db3 on Windows.'" optional string

src/node/config/config.cpp

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -131,31 +131,30 @@ EndpointVector parse_endpoints(std::string csv)
131131
int Config::process_gengetopt(gengetopt_args_info& ai)
132132
{
133133
bool dmp(ai.dump_config_given);
134-
if (!dmp){
134+
if (!dmp) {
135135
spdlog::info("Warthog Node v{}.{}.{} ", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH);
136-
std::cout<<
137-
" %%% \n"
138-
" .%%%%%%%%%%%% %% \n"
139-
" %%%%%%%%%%%%%%%%%%%%%%%% \n"
140-
" %%%%%%%%%%%%%%%%%%%%%%%#%% \n"
141-
" =%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n"
142-
" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n"
143-
" .%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%( )%% \n"
144-
" .%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n"
145-
" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n"
146-
" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@\n"
147-
" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n"
148-
" .%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%= *%%%%%%% \n"
149-
" * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n"
150-
" %%%%%%%%%%%%%%%%%%%%%%%%%%%= %%%%%%%%%%%%%%% \n"
151-
" %%%%%%%%%%%%%%%%%%%%%%%% %%+ @%%%%%%% \n"
152-
" %%%%%%%%%%%%%%%%%%%% .%%%%%%%%. %%%%%%% \n"
153-
" %%%%%%%%%%%%%%%= %%%%%% %%% \n"
154-
" %%%%%%%%%%% @ %%%%% \n"
155-
" %%%%%%%%. %%%% \n"
156-
" %%%%%%%. %%%%%% \n"
157-
" %%%%%%. %%%%%% \n"
158-
" %%%%%. %%%%%%% \n\n";
136+
std::cout << " %%% \n"
137+
" .%%%%%%%%%%%% %% \n"
138+
" %%%%%%%%%%%%%%%%%%%%%%%% \n"
139+
" %%%%%%%%%%%%%%%%%%%%%%%#%% \n"
140+
" =%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n"
141+
" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n"
142+
" .%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%( )%% \n"
143+
" .%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n"
144+
" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n"
145+
" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@\n"
146+
" %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n"
147+
" .%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%= *%%%%%%% \n"
148+
" * %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \n"
149+
" %%%%%%%%%%%%%%%%%%%%%%%%%%%= %%%%%%%%%%%%%%% \n"
150+
" %%%%%%%%%%%%%%%%%%%%%%%% %%+ @%%%%%%% \n"
151+
" %%%%%%%%%%%%%%%%%%%% .%%%%%%%%. %%%%%%% \n"
152+
" %%%%%%%%%%%%%%%= %%%%%% %%% \n"
153+
" %%%%%%%%%%% @ %%%%% \n"
154+
" %%%%%%%%. %%%% \n"
155+
" %%%%%%%. %%%%%% \n"
156+
" %%%%%%. %%%%%% \n"
157+
" %%%%%. %%%%%%% \n\n";
159158
}
160159

161160
// Log
@@ -381,6 +380,15 @@ int Config::process_gengetopt(gengetopt_args_info& ai)
381380
node.bind = EndpointAddress::parse("0.0.0.0:9186").value();
382381
}
383382
}
383+
if (ai.minfee_given) {
384+
using namespace std::string_literals;
385+
386+
try {
387+
node.minMempoolFee = CompactUInt::compact(Funds::parse_throw(ai.minfee_arg), true);
388+
} catch (...) {
389+
throw std::runtime_error("Can't parse minimal fee '"s + std::string(ai.minfee_arg) + "'."s);
390+
}
391+
}
384392
if (ai.connect_given) {
385393
peers.connect = parse_endpoints(ai.connect_arg);
386394
}

src/node/main.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "api/http/endpoint.hpp"
2-
#include "asyncio/conman.hpp"
32
#include "api/stratum/stratum_server.hpp"
3+
#include "asyncio/conman.hpp"
44
#include "chainserver/server.hpp"
55
#include "db/chain_db.hpp"
66
#include "db/peer_db.hpp"
@@ -84,6 +84,7 @@ int main(int argc, char** argv)
8484
spdlog::flush_every(5s);
8585
spdlog::info("Chain database: {}", config().data.chaindb);
8686
spdlog::info("Peers database: {}", config().data.peersdb);
87+
spdlog::info("Minimal transaction fee: {} WART", config().node.minMempoolFee.load().to_string());
8788

8889
// spdlog::flush_on(spdlog::level::debug);
8990
/////////////////////
@@ -98,7 +99,7 @@ int main(int argc, char** argv)
9899

99100
spdlog::debug("Opening chain database \"{}\"", config().data.chaindb);
100101
ChainDB db(config().data.chaindb);
101-
auto cs =ChainServer::make_chain_server(db, breg, config().node.snapshotSigner);
102+
auto cs = ChainServer::make_chain_server(db, breg, config().node.snapshotSigner);
102103

103104
std::optional<StratumServer> stratumServer;
104105
if (config().stratumPool) {
@@ -114,7 +115,7 @@ int main(int argc, char** argv)
114115

115116
// starting endpoint
116117
HTTPEndpoint endpoint { config().jsonrpc.bind };
117-
auto endpointPublic { HTTPEndpoint::make_public_endpoint(config())};
118+
auto endpointPublic { HTTPEndpoint::make_public_endpoint(config()) };
118119

119120
// setup globals
120121
global_init(&breg, &ps, &*cs, &cm, &el, &endpoint);

0 commit comments

Comments
 (0)