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

Function execute_command

src/Chain/libraries/cli/Cli.cpp:687–1239  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

685 }
686
687 fc::variant execute_command(const string& command, const fc::variants& arguments)
688 {
689 try {
690 //if in sandbox, the command must be sandbox like command
691 if (_client->get_chain()->get_is_in_sandbox())
692 {
693 sandbox_set_cmd_limit();
694
695 std::vector<std::string>::const_iterator pos = std::find(cmd_limit.begin(), cmd_limit.end(), command);
696 if (pos == cmd_limit.end())
697 {
698 *_out << "In sandbox you can not execute this command! \n";
699
700 FC_THROW_EXCEPTION(thinkyoung::cli::abort_cli_command, "");
701 }
702
703 //if already in sandbox, call sandbox_open should show prompt
704 if (command == "sandbox_open")
705 {
706 *_out << "You are already in sandbox which means if you call sandbox_open again, the state will be reset! \n";
707 *_out << "So if you mean to do this operation, please close the sandbox first.\n";
708
709 FC_THROW_EXCEPTION(thinkyoung::cli::abort_cli_command, "");
710 }
711
712 }
713
714 while (true)
715 {
716 // try to execute the method. If the method needs the wallet to be
717 // unlocked, it will throw an exception, and we'll attempt to
718 // unlock it and then retry the command
719 bool wallet_open_needed = false;
720 bool wallet_lock_needed = false;
721 //sandbox related
722 bool sandbox_open_needed = false;
723
724 try
725 {
726 return _rpc_server->direct_invoke_method(command, arguments);
727 }
728 catch (const rpc_wallet_open_needed_exception&)
729 {
730 wallet_open_needed = true;
731 }
732 catch (const rpc_wallet_unlock_needed_exception&)
733 {
734 wallet_lock_needed = true;
735 }
736 catch (const rpc_sandbox_open_needed_exception&)
737 {
738 sandbox_open_needed = true;
739 }
740
741 if (wallet_open_needed)
742 interactive_open_wallet();
743 else if (wallet_lock_needed)
744 {

Callers 1

Calls 10

sandbox_set_cmd_limitFunction · 0.85
interactive_open_walletFunction · 0.85
interactive_open_sandboxFunction · 0.85
get_is_in_sandboxMethod · 0.80
get_chainMethod · 0.80
findFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
direct_invoke_methodMethod · 0.45

Tested by

no test coverage detected