adding support for 7 arg rpc calls

This commit is contained in:
Daniel Larimer 2014-06-06 22:46:28 -04:00
parent d046526974
commit 17117bc6bf
3 changed files with 59 additions and 4 deletions

View file

@ -326,17 +326,19 @@ do { if( !(TEST) ) { FC_THROW_EXCEPTION( fc::assert_exception, #TEST ": " __VA_
FC_LOG_MESSAGE( LOG_LEVEL, FORMAT,__VA_ARGS__), \
std::current_exception() ); \
}
#define FC_CAPTURE_AND_RETHROW( SEQ ) \
#define FC_CAPTURE_AND_RETHROW( __VA_ARGS__ ) \
catch( fc::exception& er ) { \
FC_RETHROW_EXCEPTION( er, fc::log_level::warn, "", FC_FORMAT_ARG_PARAMS(SEQ) ); \
FC_RETHROW_EXCEPTION( er, warn, "", FC_FORMAT_ARG_PARAMS(__VA_ARGS__) ); \
} catch( const std::exception& e ) { \
fc::exception fce( \
FC_LOG_MESSAGE( fc::log_level::warn, "${what}",FC_FORMAT_ARG_PARAMS(SEQ)("what",e.what())), \
FC_LOG_MESSAGE( warn, "${what}",FC_FORMAT_ARG_PARAMS(__VA_ARGS__)("what",e.what())), \
fc::std_exception_code,\
typeid(e).name(), \
e.what() ) ; throw fce;\
} catch( ... ) { \
throw fc::unhandled_exception( \
FC_LOG_MESSAGE( fc::log_level::warn, "",FC_FORMAT_ARG_PARAMS(SEQ)), \
FC_LOG_MESSAGE( warn, "",FC_FORMAT_ARG_PARAMS(__VA_ARGS__)), \
std::current_exception() ); \
}

View file

@ -97,6 +97,16 @@ namespace fc { namespace rpc {
const variant& a5,
const variant& a6 );
future<variant> async_call( const fc::string& method,
const variant& a1,
const variant& a2,
const variant& a3,
const variant& a4,
const variant& a5,
const variant& a6,
const variant& a7
);
template<typename Result>
Result call( const fc::string& method,
const variant& a1,
@ -142,6 +152,19 @@ namespace fc { namespace rpc {
{
return async_call( method, a1, a2, a3, a4, a5, a6).wait(timeout).as<Result>();
}
template<typename Result>
Result call( const fc::string& method,
const variant& a1,
const variant& a2,
const variant& a3,
const variant& a4,
const variant& a5,
const variant& a6,
const variant& a7,
microseconds timeout = microseconds::maximum())
{
return async_call( method, a1, a2, a3, a4, a5, a6,7).wait(timeout).as<Result>();
}
template<typename Result>
Result call( const fc::string& method,

View file

@ -488,6 +488,36 @@ namespace fc { namespace rpc {
my->_out->flush();
return my->_awaiting[id];
}
future<variant> json_connection::async_call( const fc::string& method, const variant& a1, const variant& a2, const variant& a3, const variant& a4, const variant& a5, const variant& a6, const variant& a7 )
{
auto id = my->_next_id++;
my->_awaiting[id] = fc::promise<variant>::ptr( new fc::promise<variant>() );
{
fc::scoped_lock<fc::mutex> lock(my->_write_mutex);
*my->_out << "{\"id\":";
*my->_out << id;
*my->_out << ",\"method\":";
json::to_stream( *my->_out, method );
*my->_out << ",\"params\":[";
fc::json::to_stream( *my->_out, a1 );
*my->_out << ",";
fc::json::to_stream( *my->_out, a2 );
*my->_out << ",";
fc::json::to_stream( *my->_out, a3 );
*my->_out << ",";
fc::json::to_stream( *my->_out, a4 );
*my->_out << ",";
fc::json::to_stream( *my->_out, a5 );
*my->_out << ",";
fc::json::to_stream( *my->_out, a6 );
*my->_out << ",";
fc::json::to_stream( *my->_out, a7 );
*my->_out << "]}\n";
}
my->_out->flush();
return my->_awaiting[id];
}
future<variant> json_connection::async_call( const fc::string& method, mutable_variant_object named_args )
{