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

Method configure_rpc_server

src/Chain/libraries/client/Client.cpp:502–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

500
501 namespace detail {
502 void ClientImpl::configure_rpc_server(Config& cfg,
503 const program_options::variables_map& option_variables) {
504 if (option_variables.count("server") || option_variables.count("daemon") || cfg.rpc.enable) {
505 // the user wants us to launch the RPC server.
506 // First, override any config parameters they // thinkyoung::rpc::rpc_server::config rpc_config(cfg.rpc);
507 if (option_variables.count("rpcuser"))
508 cfg.rpc.rpc_user = option_variables["rpcuser"].as<string>();
509
510 if (option_variables.count("rpcpassword"))
511 cfg.rpc.rpc_password = option_variables["rpcpassword"].as<string>();
512
513 if (option_variables.count("rpcendpoint"))
514 cfg.rpc.rpc_endpoint = fc::ip::endpoint::from_string(option_variables["rpcendpoint"].as<string>());
515
516 if (option_variables.count("rpcport"))
517 cfg.rpc.rpc_endpoint.set_port(option_variables["rpcport"].as<uint16_t>());
518
519 if (option_variables.count("httpdendpoint"))
520 cfg.rpc.httpd_endpoint = fc::ip::endpoint::from_string(option_variables["httpdendpoint"].as<string>());
521
522 if (option_variables.count("httpport"))
523 cfg.rpc.httpd_endpoint.set_port(option_variables["httpport"].as<uint16_t>());
524
525 if (cfg.rpc.rpc_user.empty() ||
526 cfg.rpc.rpc_password.empty()) {
527 std::cout << "Error starting RPC server\n";
528 std::cout << "You specified " << (option_variables.count("server") ? "--server" : "--daemon") << " on the command line,\n";
529 std::cout << "but did not provide a username or password to authenticate RPC connections.\n";
530 std::cout << "You can provide these by using --rpcuser=username and --rpcpassword=password on the\n";
531 std::cout << "command line, or by setting the \"rpc_user\" and \"rpc_password\" properties in the\n";
532 std::cout << "config file.\n";
533 exit(1);
534 }
535
536 // launch the RPC servers
537 bool rpc_success = _rpc_server->configure_rpc(cfg.rpc);
538 rpc_success &= _rpc_server->configure_http(cfg.rpc);
539
540 if (!cfg.rpc.encrypted_rpc_wif_key.empty())
541 rpc_success &= _rpc_server->configure_encrypted_rpc(cfg.rpc);
542
543 // this shouldn't fail due to the above checks, but just to be safe...
544 if (!rpc_success)
545 std::cerr << "Error starting rpc server\n\n";
546
547 fc::optional<fc::ip::endpoint> actual_rpc_endpoint = _rpc_server->get_rpc_endpoint();
548
549 if (actual_rpc_endpoint) {
550 std::cout << "Starting JSON RPC server on port " << actual_rpc_endpoint->port();
551
552 if (actual_rpc_endpoint->get_address() == fc::ip::address("127.0.0.1"))
553 std::cout << " (localhost only)";
554
555 std::cout << "\n";
556 }
557
558 fc::optional<fc::ip::endpoint> actual_httpd_endpoint = _rpc_server->get_httpd_endpoint();
559

Callers 1

Calls 12

from_stringFunction · 0.85
set_portMethod · 0.80
configure_rpcMethod · 0.80
configure_httpMethod · 0.80
get_rpc_endpointMethod · 0.80
portMethod · 0.80
get_httpd_endpointMethod · 0.80
addressClass · 0.50
countMethod · 0.45
emptyMethod · 0.45
get_addressMethod · 0.45

Tested by

no test coverage detected