SON connection pool.

This commit is contained in:
timur 2022-11-16 07:32:17 -04:00
parent 16431b3be5
commit 9fc3536638
3 changed files with 30 additions and 26 deletions

View file

@ -47,7 +47,7 @@ public:
bool settle_sidechain_transaction(const sidechain_transaction_object &sto, asset &settle_amount); bool settle_sidechain_transaction(const sidechain_transaction_object &sto, asset &settle_amount);
private: private:
std::string rpc_url; std::vector<std::string> rpc_urls;
std::string rpc_user; std::string rpc_user;
std::string rpc_password; std::string rpc_password;
std::string wallet_account_name; std::string wallet_account_name;

View file

@ -195,7 +195,7 @@ void peerplays_sidechain_plugin_impl::plugin_set_program_options(
"Tuple of [Ethereum public key, Ethereum private key] (may specify multiple times)"); "Tuple of [Ethereum public key, Ethereum private key] (may specify multiple times)");
cli.add_options()("hive-sidechain-enabled", bpo::value<bool>()->default_value(false), "Hive sidechain handler enabled"); cli.add_options()("hive-sidechain-enabled", bpo::value<bool>()->default_value(false), "Hive sidechain handler enabled");
cli.add_options()("hive-node-rpc-url", bpo::value<string>()->default_value("127.0.0.1:28090"), "Hive node RPC URL [http[s]://]host[:port]"); cli.add_options()("hive-node-rpc-url", bpo::value<vector<string>>()->composing()->multitoken()->DEFAULT_VALUE_VECTOR("127.0.0.1:28090"), "Hive node RPC URL [http[s]://]host[:port]");
cli.add_options()("hive-node-rpc-user", bpo::value<string>(), "Hive node RPC user"); cli.add_options()("hive-node-rpc-user", bpo::value<string>(), "Hive node RPC user");
cli.add_options()("hive-node-rpc-password", bpo::value<string>(), "Hive node RPC password"); cli.add_options()("hive-node-rpc-password", bpo::value<string>(), "Hive node RPC password");
cli.add_options()("hive-wallet-account-name", bpo::value<string>(), "Hive wallet account name"); cli.add_options()("hive-wallet-account-name", bpo::value<string>(), "Hive wallet account name");

View file

@ -120,7 +120,7 @@ sidechain_net_handler_hive::sidechain_net_handler_hive(peerplays_sidechain_plugi
debug_rpc_calls = options.at("debug-rpc-calls").as<bool>(); debug_rpc_calls = options.at("debug-rpc-calls").as<bool>();
} }
rpc_url = options.at("hive-node-rpc-url").as<std::string>(); rpc_urls = options.at("hive-node-rpc-url").as<std::vector<std::string>>();
if (options.count("hive-rpc-user")) { if (options.count("hive-rpc-user")) {
rpc_user = options.at("hive-rpc-user").as<std::string>(); rpc_user = options.at("hive-rpc-user").as<std::string>();
} else { } else {
@ -146,9 +146,10 @@ sidechain_net_handler_hive::sidechain_net_handler_hive(peerplays_sidechain_plugi
} }
} }
for (const std::string &rpc_url : rpc_urls) {
hive_rpc_client *rpc_client = new hive_rpc_client(rpc_url, rpc_user, rpc_password, debug_rpc_calls); hive_rpc_client *rpc_client = new hive_rpc_client(rpc_url, rpc_user, rpc_password, debug_rpc_calls);
rpc_clients.push_back(rpc_client); rpc_clients.push_back(rpc_client);
n_active_rpc_client = 0;
const std::string chain_id_str = rpc_client->get_chain_id(); const std::string chain_id_str = rpc_client->get_chain_id();
if (chain_id_str.empty()) { if (chain_id_str.empty()) {
@ -170,6 +171,9 @@ sidechain_net_handler_hive::sidechain_net_handler_hive(peerplays_sidechain_plugi
hive::asset::hive_symbol_ser = TESTS_SYMBOL_SER; hive::asset::hive_symbol_ser = TESTS_SYMBOL_SER;
hive::public_key_type::prefix = KEY_PREFIX_TST; hive::public_key_type::prefix = KEY_PREFIX_TST;
} }
}
n_active_rpc_client = 0;
last_block_received = 0; last_block_received = 0;
schedule_hive_listener(); schedule_hive_listener();