diff --git a/src/ripple/app/main/Main.cpp b/src/ripple/app/main/Main.cpp index 784ca5bd04..4c8e945f6d 100644 --- a/src/ripple/app/main/Main.cpp +++ b/src/ripple/app/main/Main.cpp @@ -126,6 +126,7 @@ void printHelp (const po::options_description& desc) " random\n" " ripple ...\n" " ripple_path_find []\n" + " version\n" " server_info\n" " stop\n" " tx \n" diff --git a/src/ripple/net/impl/RPCCall.cpp b/src/ripple/net/impl/RPCCall.cpp index 1dc6af52f5..2004f7e555 100644 --- a/src/ripple/net/impl/RPCCall.cpp +++ b/src/ripple/net/impl/RPCCall.cpp @@ -921,6 +921,7 @@ public: { "unl_score", &RPCParser::parseAsIs, 0, 0 }, { "validation_create", &RPCParser::parseValidationCreate, 0, 1 }, { "validation_seed", &RPCParser::parseValidationSeed, 0, 1 }, + { "version", &RPCParser::parseAsIs, 0, 0 }, { "wallet_accounts", &RPCParser::parseWalletAccounts, 1, 1 }, { "wallet_propose", &RPCParser::parseWalletPropose, 0, 1 }, { "wallet_seed", &RPCParser::parseWalletSeed, 0, 1 }, diff --git a/src/ripple/protocol/JsonFields.h b/src/ripple/protocol/JsonFields.h index 51423fdbbe..f97135c3d3 100644 --- a/src/ripple/protocol/JsonFields.h +++ b/src/ripple/protocol/JsonFields.h @@ -81,14 +81,17 @@ JSS ( expand ); JSS ( fee_base ); JSS ( fee_ref ); JSS ( fetch_pack ); +JSS ( first ); JSS ( flags ); JSS ( freeze ); JSS ( freeze_peer ); JSS ( full ); +JSS ( good ); JSS ( hash ); JSS ( hostid ); JSS ( id ); JSS ( issuer ); +JSS ( last ); JSS ( last_close ); JSS ( ledger ); JSS ( ledgerClosed ); @@ -175,6 +178,7 @@ JSS ( validated_ledger ); JSS ( validated_ledgers ); JSS ( validation_quorum ); JSS ( value ); +JSS ( version ); JSS ( waiting ); JSS ( warning ); diff --git a/src/ripple/rpc/Output.h b/src/ripple/rpc/Output.h index 1584afe70d..7bcd7ffa3a 100644 --- a/src/ripple/rpc/Output.h +++ b/src/ripple/rpc/Output.h @@ -17,8 +17,8 @@ */ //============================================================================== -#ifndef RIPPLED_RIPPLE_BASICS_TYPES_OUTPUT_H -#define RIPPLED_RIPPLE_BASICS_TYPES_OUTPUT_H +#ifndef RIPPLE_RPC_OUTPUT_H_INCLUDED +#define RIPPLE_RPC_OUTPUT_H_INCLUDED #include diff --git a/src/ripple/rpc/RPCVersion.h b/src/ripple/rpc/RPCVersion.h new file mode 100644 index 0000000000..f63a7c9d21 --- /dev/null +++ b/src/ripple/rpc/RPCVersion.h @@ -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 +#include +#include + +namespace ripple { +namespace RPC { + +extern beast::SemanticVersion const firstVersion; +extern beast::SemanticVersion const goodVersion; +extern beast::SemanticVersion const lastVersion; + +template +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 diff --git a/src/ripple/rpc/handlers/Version.h b/src/ripple/rpc/handlers/Version.h new file mode 100644 index 0000000000..1c5c99d3d7 --- /dev/null +++ b/src/ripple/rpc/handlers/Version.h @@ -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 + +namespace ripple { +namespace RPC { + +class VersionHandler +{ +public: + explicit VersionHandler (Context&) {} + + Status check() + { + return Status::OK; + } + + template + 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 diff --git a/src/ripple/rpc/impl/Handler.cpp b/src/ripple/rpc/impl/Handler.cpp index 58f2fae8d6..e58bb1a08c 100644 --- a/src/ripple/rpc/impl/Handler.cpp +++ b/src/ripple/rpc/impl/Handler.cpp @@ -20,6 +20,8 @@ #include #include #include +#include +#include namespace ripple { namespace RPC { @@ -66,6 +68,7 @@ class HandlerTable { // This is where the new-style handlers are added. addHandler(); + addHandler(); } const Handler* getHandler(std::string name) { diff --git a/src/ripple/rpc/impl/RPCVersion.cpp b/src/ripple/rpc/impl/RPCVersion.cpp new file mode 100644 index 0000000000..8317c27184 --- /dev/null +++ b/src/ripple/rpc/impl/RPCVersion.cpp @@ -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 + +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 diff --git a/src/ripple/unity/rpcx.cpp b/src/ripple/unity/rpcx.cpp index e05e0a386e..027cbd6746 100644 --- a/src/ripple/unity/rpcx.cpp +++ b/src/ripple/unity/rpcx.cpp @@ -103,6 +103,7 @@ #include #include #include +#include #include #include