SON conn. pool
This commit is contained in:
parent
ac2c9e16e6
commit
c4f3f37075
6 changed files with 20 additions and 7 deletions
|
|
@ -57,7 +57,8 @@ public:
|
|||
std::string sendrawtransaction(const std::string &tx_hex);
|
||||
std::string walletlock();
|
||||
bool walletpassphrase(const std::string &passphrase, uint32_t timeout = 60);
|
||||
uint64_t ping(rpc_connection &conn) const;
|
||||
|
||||
virtual uint64_t ping(rpc_connection &conn) const override;
|
||||
|
||||
private:
|
||||
std::string ip;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@ public:
|
|||
std::string eth_send_transaction(const std::string ¶ms);
|
||||
std::string eth_send_raw_transaction(const std::string ¶ms);
|
||||
std::string eth_get_transaction_receipt(const std::string ¶ms);
|
||||
|
||||
virtual uint64_t ping(rpc_connection &conn) const override;
|
||||
};
|
||||
|
||||
class sidechain_net_handler_ethereum : public sidechain_net_handler {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,8 @@ public:
|
|||
std::string get_head_block_time();
|
||||
std::string get_is_test_net();
|
||||
std::string get_last_irreversible_block_num();
|
||||
uint64_t ping(rpc_connection &conn) const;
|
||||
|
||||
virtual uint64_t ping(rpc_connection &conn) const override;
|
||||
};
|
||||
|
||||
class sidechain_net_handler_hive : public sidechain_net_handler {
|
||||
|
|
|
|||
|
|
@ -244,8 +244,7 @@ bool bitcoin_rpc_client::walletpassphrase(const std::string &passphrase, uint32_
|
|||
return true;
|
||||
}
|
||||
|
||||
uint64_t bitcoin_rpc_client::ping(rpc_connection &conn) const
|
||||
{
|
||||
uint64_t bitcoin_rpc_client::ping(rpc_connection &conn) const {
|
||||
return std::numeric_limits<uint64_t>::max();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,10 @@ std::string ethereum_rpc_client::eth_get_transaction_receipt(const std::string &
|
|||
return send_post_request("eth_getTransactionReceipt", "[\"" + params + "\"]", debug_rpc_calls);
|
||||
}
|
||||
|
||||
uint64_t ethereum_rpc_client::ping(rpc_connection &conn) const {
|
||||
return std::numeric_limits<uint64_t>::max();
|
||||
}
|
||||
|
||||
sidechain_net_handler_ethereum::sidechain_net_handler_ethereum(peerplays_sidechain_plugin &_plugin, const boost::program_options::variables_map &options) :
|
||||
sidechain_net_handler(_plugin, options) {
|
||||
sidechain = sidechain_type::ethereum;
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ sidechain_net_handler_hive::sidechain_net_handler_hive(peerplays_sidechain_plugi
|
|||
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")) {
|
||||
rpc_user = options.at("hive-rpc-user").as<std::string>();
|
||||
} else {
|
||||
|
|
@ -159,11 +159,17 @@ sidechain_net_handler_hive::sidechain_net_handler_hive(peerplays_sidechain_plugi
|
|||
}
|
||||
}
|
||||
|
||||
rpc_client = new hive_rpc_client(rpc_url, rpc_user, rpc_password, debug_rpc_calls);
|
||||
std::vector<std::string> rpc_users, rpc_passwords;
|
||||
for (size_t i=0; i < rpc_urls.size(); i++) {
|
||||
rpc_users.push_back(rpc_user);
|
||||
rpc_passwords.push_back(rpc_password);
|
||||
}
|
||||
|
||||
rpc_client = new hive_rpc_client(rpc_urls, rpc_users, rpc_passwords, debug_rpc_calls);
|
||||
|
||||
const std::string chain_id_str = rpc_client->get_chain_id();
|
||||
if (chain_id_str.empty()) {
|
||||
elog("No Hive node running at ${url}", ("url", rpc_url));
|
||||
elog("No Hive node running at ${url}", ("url", rpc_urls[0]));
|
||||
FC_ASSERT(false);
|
||||
}
|
||||
chain_id = chain_id_type(chain_id_str);
|
||||
|
|
|
|||
Loading…
Reference in a new issue