mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-19 19:25:53 +00:00
add random and ping
This commit is contained in:
@@ -79,5 +79,8 @@ doUnsubscribe(Context const& context);
|
||||
Result
|
||||
doServerInfo(Context const& context);
|
||||
|
||||
// Utility methods
|
||||
Result
|
||||
doRandom(Context const& context);
|
||||
} // namespace RPC
|
||||
#endif
|
||||
|
||||
@@ -110,7 +110,8 @@ static std::unordered_map<std::string, std::function<Result(Context const&)>>
|
||||
{"server_info", &doServerInfo},
|
||||
{"unsubscribe", &doUnsubscribe},
|
||||
{"tx", &doTx},
|
||||
{"transaction_entry", &doTransactionEntry}};
|
||||
{"transaction_entry", &doTransactionEntry},
|
||||
{"random", &doRandom}};
|
||||
|
||||
static std::unordered_set<std::string> forwardCommands{
|
||||
"submit",
|
||||
@@ -155,6 +156,8 @@ buildResponse(Context const& ctx)
|
||||
return Status{Error::rpcFAILED_TO_FORWARD};
|
||||
return res;
|
||||
}
|
||||
if (ctx.method == "ping")
|
||||
return boost::json::object{};
|
||||
|
||||
if (handlerTable.find(ctx.method) == handlerTable.end())
|
||||
return Status{Error::rpcUNKNOWN_COMMAND};
|
||||
|
||||
16
src/rpc/handlers/Random.cpp
Normal file
16
src/rpc/handlers/Random.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <ripple/beast/utility/rngfill.h>
|
||||
#include <ripple/crypto/csprng.h>
|
||||
#include <rpc/RPCHelpers.h>
|
||||
namespace RPC {
|
||||
|
||||
Result
|
||||
doRandom(Context const& context)
|
||||
{
|
||||
ripple::uint256 rand;
|
||||
|
||||
beast::rngfill(rand.begin(), rand.size(), ripple::crypto_prng());
|
||||
boost::json::object result;
|
||||
result["random"] = ripple::strHex(rand);
|
||||
return result;
|
||||
}
|
||||
} // namespace RPC
|
||||
Reference in New Issue
Block a user