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

Method configure_rpc

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

Source from the content-addressed store, hash-verified

1608 }
1609
1610 bool RpcServer::configure_rpc(const RpcServerConfig& cfg)
1611 {
1612 if (!cfg.is_valid())
1613 return false;
1614 my->_cache_enabled = cfg.enable_cache;
1615
1616 try
1617 {
1618 my->_config = cfg;
1619 my->_tcp_serv = std::make_shared<fc::tcp_server>();
1620 int attempts = 0;
1621 bool success = false;
1622
1623 while (!success) {
1624 try
1625 {
1626 my->_tcp_serv->listen(cfg.rpc_endpoint);
1627 success = true;
1628 }
1629 catch (fc::exception& e)
1630 {
1631 FC_ASSERT(++attempts < 30, "Unable to bind RPC port; refusing to continue.");
1632 ulog("Failed to bind RPC port ${endpoint}; waiting 10 seconds and retrying (attempt ${attempt}/30)",
1633 ("endpoint", cfg.rpc_endpoint)("attempt", attempts));
1634 elog("Failed to bind RPC port ${endpoint} with error ${e}", ("endpoint", cfg.rpc_endpoint)("e", e.to_detail_string()));
1635 }
1636 if (!success)
1637 fc::usleep(fc::seconds(10));
1638 }
1639
1640 ilog("listening for json rpc connections on port ${port}", ("port", my->_tcp_serv->get_port()));
1641
1642 my->_accept_loop_complete = fc::async([=]{ my->accept_loop(); }, "rpc_server accept_loop");
1643
1644 return true;
1645 } FC_RETHROW_EXCEPTIONS(warn, "attempting to configure rpc server ${port}", ("port", cfg.rpc_endpoint)("config", cfg));
1646 }
1647
1648 bool RpcServer::configure_http(const RpcServerConfig& cfg)
1649 {

Callers 2

rpc_start_serverMethod · 0.80
configure_rpc_serverMethod · 0.80

Calls 5

secondsFunction · 0.50
asyncFunction · 0.50
is_validMethod · 0.45
listenMethod · 0.45
accept_loopMethod · 0.45

Tested by

no test coverage detected