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

Method configure_http

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

Source from the content-addressed store, hash-verified

1646 }
1647
1648 bool RpcServer::configure_http(const RpcServerConfig& cfg)
1649 {
1650 if (!cfg.is_valid())
1651 return false;
1652
1653 my->_cache_enabled = cfg.enable_cache;
1654
1655 try
1656 {
1657 my->_config = cfg;
1658 auto m = my.get();
1659 my->_httpd = std::make_shared<fc::http::server>();
1660 int attempts = 0;
1661 bool success = false;
1662
1663 while (!success) {
1664 try
1665 {
1666 my->_httpd->listen(cfg.httpd_endpoint);
1667 success = true;
1668 }
1669 catch (fc::exception& e)
1670 {
1671 FC_ASSERT(++attempts < 30, "Unable to bind HTTPD port; refusing to continue.");
1672 ulog("Failed to bind HTTPD port ${endpoint}; waiting 10 seconds and retrying (attempt ${attempt}/30)",
1673 ("endpoint", cfg.httpd_endpoint)("attempt", attempts));
1674 elog("Failed to bind HTTPD port ${endpoint} with error ${e}", ("endpoint", cfg.rpc_endpoint)("e", e.to_detail_string()));
1675 }
1676 if (!success)
1677 fc::usleep(fc::seconds(10));
1678 }
1679
1680 my->_httpd->on_request([m](const fc::http::request& r, const fc::http::server::response& s){ m->handle_request(r, s); });
1681 return true;
1682 } FC_RETHROW_EXCEPTIONS(warn, "attempting to configure rpc server ${port}", ("port", cfg.rpc_endpoint)("config", cfg));
1683 }
1684
1685 bool RpcServer::configure_encrypted_rpc(const RpcServerConfig& cfg)
1686 {

Callers 2

http_start_serverMethod · 0.80
configure_rpc_serverMethod · 0.80

Calls 5

handle_requestMethod · 0.80
secondsFunction · 0.50
is_validMethod · 0.45
getMethod · 0.45
listenMethod · 0.45

Tested by

no test coverage detected