MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / configure_encrypted_rpc

Method configure_encrypted_rpc

src/Chain/libraries/rpc/RpcServer.cpp:1685–1733  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1683 }
1684
1685 bool RpcServer::configure_encrypted_rpc(const RpcServerConfig& cfg)
1686 {
1687 if (!cfg.is_valid())
1688 return false;
1689 my->_cache_enabled = cfg.enable_cache;
1690 if (cfg.encrypted_rpc_wif_key.empty())
1691 {
1692 std::cerr << ("No WIF");
1693 return false;
1694 }
1695 auto server_key = utilities::wif_to_key(cfg.encrypted_rpc_wif_key);
1696 if (!server_key.valid())
1697 {
1698 std::cerr << ("Invalid WIF");
1699 return false;
1700 }
1701
1702 try
1703 {
1704 my->_config = cfg;
1705 my->_stcp_serv = std::make_shared<fc::tcp_server>();
1706 int attempts = 0;
1707 bool success = false;
1708
1709 while (!success) {
1710 try
1711 {
1712 my->_stcp_serv->listen(cfg.encrypted_rpc_endpoint);
1713 success = true;
1714 }
1715 catch (fc::exception& e)
1716 {
1717 FC_ASSERT(++attempts < 30, "Unable to bind encrypted RPC port; refusing to continue.");
1718 ulog("Failed to bind encrypted RPC port ${endpoint}; waiting 10 seconds and retrying (attempt ${attempt}/30)",
1719 ("endpoint", cfg.encrypted_rpc_endpoint)("attempt", attempts));
1720 elog("Failed to bind encrypted RPC port ${endpoint} with error ${e}", ("endpoint", cfg.encrypted_rpc_endpoint)("e", e.to_detail_string()));
1721 }
1722 if (!success)
1723 fc::usleep(fc::seconds(10));
1724 }
1725
1726 ilog("listening for encrypted json rpc connections on port ${port}", ("port", my->_stcp_serv->get_port()));
1727
1728 my->_encrypted_accept_loop_complete = fc::async([=]{ my->encrypted_accept_loop(*server_key); }, "rpc_server accept_loop");
1729
1730 return true;
1731 } FC_RETHROW_EXCEPTIONS(warn, "attempting to configure rpc server ${port}", ("port", cfg.encrypted_rpc_endpoint)("config", cfg));
1732
1733 }
1734
1735 fc::variant RpcServer::direct_invoke_method(const std::string& method_name, const fc::variants& arguments)
1736 {

Callers 1

configure_rpc_serverMethod · 0.80

Calls 8

wif_to_keyFunction · 0.85
encrypted_accept_loopMethod · 0.80
secondsFunction · 0.50
asyncFunction · 0.50
is_validMethod · 0.45
emptyMethod · 0.45
validMethod · 0.45
listenMethod · 0.45

Tested by

no test coverage detected