parent
					
						
							
								608b4c4765
							
						
					
				
			
			
				commit
				
					
						d9af3a4283
					
				
			
		
					 3 changed files with 39 additions and 0 deletions
				
			
		| 
						 | 
				
			
			@ -906,6 +906,26 @@ void nano::json_handler::accounts_balances ()
 | 
			
		|||
	response_errors ();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void nano::json_handler::accounts_representatives ()
 | 
			
		||||
{
 | 
			
		||||
	boost::property_tree::ptree representatives;
 | 
			
		||||
	for (auto & accounts : request.get_child ("accounts"))
 | 
			
		||||
	{
 | 
			
		||||
		auto account (account_impl (accounts.second.data ()));
 | 
			
		||||
		auto transaction (node.store.tx_begin_read ());
 | 
			
		||||
		auto info (account_info_impl (transaction, account));
 | 
			
		||||
 | 
			
		||||
		if (!ec)
 | 
			
		||||
		{
 | 
			
		||||
			boost::property_tree::ptree entry;
 | 
			
		||||
			entry.put ("", info.representative.to_account ());
 | 
			
		||||
			representatives.push_back (std::make_pair (accounts.second.data (), entry));
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	response_l.add_child ("representatives", representatives);
 | 
			
		||||
	response_errors ();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void nano::json_handler::accounts_create ()
 | 
			
		||||
{
 | 
			
		||||
	node.workers.push_task (create_worker_task ([] (std::shared_ptr<nano::json_handler> const & rpc_l) {
 | 
			
		||||
| 
						 | 
				
			
			@ -5167,6 +5187,7 @@ ipc_json_handler_no_arg_func_map create_ipc_json_handler_no_arg_func_map ()
 | 
			
		|||
	no_arg_funcs.emplace ("account_representative_set", &nano::json_handler::account_representative_set);
 | 
			
		||||
	no_arg_funcs.emplace ("account_weight", &nano::json_handler::account_weight);
 | 
			
		||||
	no_arg_funcs.emplace ("accounts_balances", &nano::json_handler::accounts_balances);
 | 
			
		||||
	no_arg_funcs.emplace ("accounts_representatives", &nano::json_handler::accounts_representatives);
 | 
			
		||||
	no_arg_funcs.emplace ("accounts_create", &nano::json_handler::accounts_create);
 | 
			
		||||
	no_arg_funcs.emplace ("accounts_frontiers", &nano::json_handler::accounts_frontiers);
 | 
			
		||||
	no_arg_funcs.emplace ("accounts_pending", &nano::json_handler::accounts_pending);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -40,6 +40,7 @@ public:
 | 
			
		|||
	void account_representative_set ();
 | 
			
		||||
	void account_weight ();
 | 
			
		||||
	void accounts_balances ();
 | 
			
		||||
	void accounts_representatives ();
 | 
			
		||||
	void accounts_create ();
 | 
			
		||||
	void accounts_frontiers ();
 | 
			
		||||
	void accounts_pending ();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2973,6 +2973,23 @@ TEST (rpc, accounts_balances)
 | 
			
		|||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST (rpc, accounts_representatives)
 | 
			
		||||
{
 | 
			
		||||
	nano::system system;
 | 
			
		||||
	auto node = add_ipc_enabled_node (system);
 | 
			
		||||
	auto [rpc, rpc_ctx] = add_rpc (system, node);
 | 
			
		||||
	boost::property_tree::ptree request;
 | 
			
		||||
	request.put ("action", "accounts_representatives");
 | 
			
		||||
	boost::property_tree::ptree entry;
 | 
			
		||||
	boost::property_tree::ptree accounts;
 | 
			
		||||
	entry.put ("", nano::dev::genesis_key.pub.to_account ());
 | 
			
		||||
	accounts.push_back (std::make_pair ("", entry));
 | 
			
		||||
	request.add_child ("accounts", accounts);
 | 
			
		||||
	auto response (wait_response (system, rpc, request));
 | 
			
		||||
	auto response_representative (response.get_child("representatives").get<std::string>(nano::dev::genesis->account ().to_account ()));
 | 
			
		||||
	ASSERT_EQ (response_representative, nano::dev::genesis->account ().to_account ());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST (rpc, accounts_frontiers)
 | 
			
		||||
{
 | 
			
		||||
	nano::system system;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue