New RPC method "version".

This commit is contained in:
Tom Ritchford
2015-01-27 16:40:01 -05:00
committed by Vinnie Falco
parent bfc436dccd
commit c3809ece67
9 changed files with 151 additions and 2 deletions

View File

@@ -126,6 +126,7 @@ void printHelp (const po::options_description& desc)
" random\n" " random\n"
" ripple ...\n" " ripple ...\n"
" ripple_path_find <json> [<ledger>]\n" " ripple_path_find <json> [<ledger>]\n"
" version\n"
" server_info\n" " server_info\n"
" stop\n" " stop\n"
" tx <id>\n" " tx <id>\n"

View File

@@ -921,6 +921,7 @@ public:
{ "unl_score", &RPCParser::parseAsIs, 0, 0 }, { "unl_score", &RPCParser::parseAsIs, 0, 0 },
{ "validation_create", &RPCParser::parseValidationCreate, 0, 1 }, { "validation_create", &RPCParser::parseValidationCreate, 0, 1 },
{ "validation_seed", &RPCParser::parseValidationSeed, 0, 1 }, { "validation_seed", &RPCParser::parseValidationSeed, 0, 1 },
{ "version", &RPCParser::parseAsIs, 0, 0 },
{ "wallet_accounts", &RPCParser::parseWalletAccounts, 1, 1 }, { "wallet_accounts", &RPCParser::parseWalletAccounts, 1, 1 },
{ "wallet_propose", &RPCParser::parseWalletPropose, 0, 1 }, { "wallet_propose", &RPCParser::parseWalletPropose, 0, 1 },
{ "wallet_seed", &RPCParser::parseWalletSeed, 0, 1 }, { "wallet_seed", &RPCParser::parseWalletSeed, 0, 1 },

View File

@@ -81,14 +81,17 @@ JSS ( expand );
JSS ( fee_base ); JSS ( fee_base );
JSS ( fee_ref ); JSS ( fee_ref );
JSS ( fetch_pack ); JSS ( fetch_pack );
JSS ( first );
JSS ( flags ); JSS ( flags );
JSS ( freeze ); JSS ( freeze );
JSS ( freeze_peer ); JSS ( freeze_peer );
JSS ( full ); JSS ( full );
JSS ( good );
JSS ( hash ); JSS ( hash );
JSS ( hostid ); JSS ( hostid );
JSS ( id ); JSS ( id );
JSS ( issuer ); JSS ( issuer );
JSS ( last );
JSS ( last_close ); JSS ( last_close );
JSS ( ledger ); JSS ( ledger );
JSS ( ledgerClosed ); JSS ( ledgerClosed );
@@ -175,6 +178,7 @@ JSS ( validated_ledger );
JSS ( validated_ledgers ); JSS ( validated_ledgers );
JSS ( validation_quorum ); JSS ( validation_quorum );
JSS ( value ); JSS ( value );
JSS ( version );
JSS ( waiting ); JSS ( waiting );
JSS ( warning ); JSS ( warning );

View File

@@ -17,8 +17,8 @@
*/ */
//============================================================================== //==============================================================================
#ifndef RIPPLED_RIPPLE_BASICS_TYPES_OUTPUT_H #ifndef RIPPLE_RPC_OUTPUT_H_INCLUDED
#define RIPPLED_RIPPLE_BASICS_TYPES_OUTPUT_H #define RIPPLE_RPC_OUTPUT_H_INCLUDED
#include <boost/utility/string_ref.hpp> #include <boost/utility/string_ref.hpp>

View File

@@ -0,0 +1,46 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLED_RIPPLE_RPC_VERSIONS_H
#define RIPPLED_RIPPLE_RPC_VERSIONS_H
#include <beast/module/core/diagnostic/SemanticVersion.h>
#include <ripple/protocol/JsonFields.h>
#include <ripple/rpc/impl/JsonObject.h>
namespace ripple {
namespace RPC {
extern beast::SemanticVersion const firstVersion;
extern beast::SemanticVersion const goodVersion;
extern beast::SemanticVersion const lastVersion;
template <class Object>
void setVersion(Object& parent)
{
auto&& object = addObject (parent, jss::version);
object[jss::first] = firstVersion.print();
object[jss::good] = goodVersion.print();
object[jss::last] = lastVersion.print();
}
} // RPC
} // ripple
#endif

View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLED_RIPPLE_RPC_HANDLERS_VERSION_H
#define RIPPLED_RIPPLE_RPC_HANDLERS_VERSION_H
#include <ripple/rpc/RPCVersion.h>
namespace ripple {
namespace RPC {
class VersionHandler
{
public:
explicit VersionHandler (Context&) {}
Status check()
{
return Status::OK;
}
template <class Object>
void writeResult (Object& obj)
{
setVersion (obj);
}
static const char* const name()
{
return "version";
}
static Role role()
{
return Role::USER;
}
static Condition condition()
{
return NO_CONDITION;
}
};
} // RPC
} // ripple
#endif

View File

@@ -20,6 +20,8 @@
#include <BeastConfig.h> #include <BeastConfig.h>
#include <ripple/rpc/impl/Handler.h> #include <ripple/rpc/impl/Handler.h>
#include <ripple/rpc/handlers/Handlers.h> #include <ripple/rpc/handlers/Handlers.h>
#include <ripple/rpc/handlers/Ledger.h>
#include <ripple/rpc/handlers/Version.h>
namespace ripple { namespace ripple {
namespace RPC { namespace RPC {
@@ -66,6 +68,7 @@ class HandlerTable {
// This is where the new-style handlers are added. // This is where the new-style handlers are added.
addHandler<LedgerHandler>(); addHandler<LedgerHandler>();
addHandler<VersionHandler>();
} }
const Handler* getHandler(std::string name) { const Handler* getHandler(std::string name) {

View File

@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <ripple/rpc/RPCVersion.h>
namespace ripple {
namespace RPC {
beast::SemanticVersion const firstVersion ("1.0.0");
beast::SemanticVersion const goodVersion ("1.0.0");
beast::SemanticVersion const lastVersion ("1.0.0");
} // RPC
} // ripple

View File

@@ -103,6 +103,7 @@
#include <ripple/rpc/impl/LookupLedger.cpp> #include <ripple/rpc/impl/LookupLedger.cpp>
#include <ripple/rpc/impl/ParseAccountIds.cpp> #include <ripple/rpc/impl/ParseAccountIds.cpp>
#include <ripple/rpc/impl/TransactionSign.cpp> #include <ripple/rpc/impl/TransactionSign.cpp>
#include <ripple/rpc/impl/RPCVersion.cpp>
#include <ripple/rpc/tests/Coroutine.test.cpp> #include <ripple/rpc/tests/Coroutine.test.cpp>
#include <ripple/rpc/tests/JsonObject.test.cpp> #include <ripple/rpc/tests/JsonObject.test.cpp>