@@ -35,6 +35,14 @@ App::~App() { close(); }
35
35
36
36
void App::addAvailablePlugin (std::shared_ptr<Plugin> plugin) { available_plugins_[plugin->name ()] = plugin; }
37
37
38
+ std::shared_ptr<Plugin> App::getPlugin (const std::string &name) const {
39
+ auto it = active_plugins_.find (name);
40
+ if (it != active_plugins_.end ()) {
41
+ return it->second ;
42
+ }
43
+ return nullptr ;
44
+ }
45
+
38
46
void App::enablePlugin (const std::string &name) {
39
47
if (available_plugins_[name] == nullptr ) {
40
48
throw std::runtime_error (" Plugin " + name + " not found" );
@@ -46,23 +54,30 @@ bool App::isPluginEnabled(const std::string &name) const { return active_plugins
46
54
47
55
void App::init (const cli::Config &cli_conf) {
48
56
conf_ = cli_conf.getNodeConfiguration ();
49
- kp_ = std::make_shared<dev::KeyPair>(conf_.node_secret );
50
57
51
58
fs::create_directories (conf_.db_path );
52
59
fs::create_directories (conf_.log_path );
53
60
54
61
// Initialize logging
55
- const auto &node_addr = kp_-> address () ;
62
+ const auto &node_addr = conf_. getFirstWallet (). node_addr ;
56
63
for (auto &logging : conf_.log_configs ) {
57
64
logging.InitLogging (node_addr);
58
65
}
59
66
60
67
LOG_OBJECTS_CREATE (" FULLND" );
61
68
62
- LOG (log_si_) << " Node public key: " << EthGreen << kp_->pub ().toString () << std::endl
63
- << EthReset << " Node address: " << EthRed << node_addr.toString () << std::endl
64
- << EthReset << " Node VRF public key: " << EthGreen
65
- << vrf_wrapper::getVrfPublicKey (conf_.vrf_secret ).toString () << EthReset;
69
+ std::string node_addresses;
70
+ std::string node_public_keys;
71
+ std::string node_vrf_public_keys;
72
+ std::for_each (conf_.wallets .begin (), conf_.wallets .end (), [&](const WalletConfig &wallet) {
73
+ node_addresses += wallet.node_addr .toString () + " " ;
74
+ node_public_keys += wallet.node_pk .toString () + " " ;
75
+ node_vrf_public_keys += wallet.vrf_pk .toString () + " " ;
76
+ });
77
+
78
+ LOG (log_si_) << " Node public keys: " << EthGreen << " [" << node_public_keys << " ]" << std::endl
79
+ << EthReset << " Node addresses: " << EthRed << " [" << node_addresses << " ]" << std::endl
80
+ << EthReset << " Node VRF public keys: " << EthGreen << " [" << node_vrf_public_keys << " ]" << EthReset;
66
81
67
82
if (!conf_.genesis .dag_genesis_block .verifySig ()) {
68
83
LOG (log_er_) << " Genesis block is invalid" ;
@@ -117,9 +132,9 @@ void App::init(const cli::Config &cli_conf) {
117
132
}
118
133
119
134
final_chain_ = std::make_shared<final_chain::FinalChain>(db_, conf_, node_addr);
120
- gas_pricer_ = std::make_shared<GasPricer>(conf_.genesis , conf_.is_light_node , db_);
121
135
key_manager_ = std::make_shared<KeyManager>(final_chain_);
122
136
trx_mgr_ = std::make_shared<TransactionManager>(conf_, db_, final_chain_, node_addr);
137
+ gas_pricer_ = std::make_shared<GasPricer>(conf_.genesis , conf_.is_light_node , conf_.blocks_gas_pricer , trx_mgr_, db_);
123
138
124
139
auto genesis_hash = conf_.genesis .genesisHash ();
125
140
auto genesis_hash_from_db = db_->getGenesisHash ();
@@ -143,9 +158,9 @@ void App::init(const cli::Config &cli_conf) {
143
158
pillar_chain_mgr_);
144
159
dag_block_proposer_ = std::make_shared<DagBlockProposer>(conf_, dag_mgr_, trx_mgr_, final_chain_, db_, key_manager_);
145
160
146
- network_ =
147
- std::make_shared<Network>(conf_, genesis_hash, conf_. net_file_path (). string (), *kp_, db_, pbft_mgr_, pbft_chain_ ,
148
- vote_mgr_, dag_mgr_, trx_mgr_, std::move (slashing_manager), pillar_chain_mgr_ );
161
+ network_ = std::make_shared<Network>(conf_, genesis_hash, conf_. net_file_path (). string (), db_, pbft_mgr_, pbft_chain_,
162
+ vote_mgr_, dag_mgr_, trx_mgr_, std::move (slashing_manager), pillar_chain_mgr_ ,
163
+ final_chain_ );
149
164
auto cli_options = cli_conf.getCliOptions ();
150
165
for (auto &plugin : active_plugins_) {
151
166
plugin.second ->init (cli_options);
@@ -192,22 +207,23 @@ void App::start() {
192
207
LOG (log_si_) << " DB migrated successfully, please restart the node without the flag" ;
193
208
started_ = false ;
194
209
return ;
195
- } else {
196
- network_->start ();
197
- dag_block_proposer_->setNetwork (network_);
198
- dag_block_proposer_->start ();
199
210
}
200
211
212
+ for (auto &plugin : active_plugins_) {
213
+ LOG (log_nf_) << " Starting plugin " << plugin.first ;
214
+ plugin.second ->start ();
215
+ }
216
+
217
+ network_->start ();
218
+ dag_block_proposer_->setNetwork (network_);
219
+ dag_block_proposer_->start ();
220
+
201
221
pbft_mgr_->start ();
202
222
203
223
if (metrics_) {
204
224
setupMetricsUpdaters ();
205
225
metrics_->start ();
206
226
}
207
- for (auto &plugin : active_plugins_) {
208
- LOG (log_nf_) << " Starting plugin " << plugin.first ;
209
- plugin.second ->start ();
210
- }
211
227
started_ = true ;
212
228
LOG (log_nf_) << " Node started ... " ;
213
229
}
@@ -218,7 +234,6 @@ void App::scheduleLoggingConfigUpdate() {
218
234
return ;
219
235
}
220
236
221
- static auto node_address = dev::KeyPair (conf_.node_secret ).address ();
222
237
config_update_executor_.post ([&]() {
223
238
while (started_ && !stopped_) {
224
239
auto path = std::filesystem::path (conf_.json_file_name );
@@ -234,7 +249,7 @@ void App::scheduleLoggingConfigUpdate() {
234
249
try {
235
250
auto config = getJsonFromFileOrString (conf_.json_file_name );
236
251
conf_.log_configs = conf_.loadLoggingConfigs (config[" logging" ]);
237
- conf_.InitLogging (node_address );
252
+ conf_.InitLogging (conf_. getFirstWallet (). node_addr );
238
253
} catch (const ConfigException &e) {
239
254
std::cerr << " FullNodeConfig: Failed to update logging config: " << e.what () << std::endl;
240
255
continue ;
0 commit comments