20 #include <ripple/app/main/Application.h>
21 #include <ripple/basics/BasicConfig.h>
22 #include <ripple/net/RPCErr.h>
23 #include <ripple/nodestore/DatabaseShard.h>
24 #include <ripple/protocol/ErrorCodes.h>
25 #include <ripple/protocol/jss.h>
26 #include <ripple/rpc/Context.h>
27 #include <ripple/rpc/ShardArchiveHandler.h>
28 #include <ripple/rpc/impl/Handler.h>
30 #include <boost/algorithm/string.hpp>
60 auto preShards{shardStore->getPreShards()};
61 if (!preShards.empty())
64 if (!
std::all_of(preShards.begin(), preShards.end(), ::isdigit))
80 for (
auto& it : context.
params[jss::shards])
83 if (!it.isMember(jss::index))
85 auto& jv{it[jss::index]};
86 if (!(jv.isUInt() || (jv.isInt() && jv.asInt() >= 0)))
93 if (!it.isMember(jss::url))
96 auto unparsedURL = it[jss::url].asString();
102 if (url.
scheme !=
"https")
107 if (archiveName.empty() || archiveName.size() <= ext.size())
111 "', invalid archive name");
113 if (!boost::iends_with(archiveName, ext))
117 "', invalid archive extension");
128 "', duplicate shard ids.");
143 rpcINTERNAL,
"Failed to create ShardArchiveHandler.");
145 if (!handler->init())
147 rpcINTERNAL,
"Failed to initiate ShardArchiveHandler.");
155 for (
auto& [index, url] : archives)
157 if (!handler->add(index, std::move(url)))
160 "Invalid field '" +
std::string(jss::index) +
"', shard id " +
166 if (!handler->start())
173 preShards = shardStore->getPreShards();
174 if (!
std::all_of(preShards.begin(), preShards.end(), ::isdigit))
Json::Value doDownloadShard(RPC::JsonContext &context)
RPC command that downloads and import shard archives.
virtual NodeStore::DatabaseShard * getShardStore()=0
Json::Value expected_field_error(std::string const &name, std::string const &type)
Json::Value missing_field_error(std::string const &name)
T find_last_of(T... args)
virtual JobQueue & getJobQueue()=0
bool parseUrl(parsedURL &pUrl, std::string const &strUrl)
UInt size() const
Number of values in array or object.
bool isMember(const char *key) const
Return true if the object has a member named key.
Json::Value rpcError(int iError, Json::Value jvResult)
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
static bool hasInstance()
Json::Value makeObjectValue(Value const &value, Json::StaticString const &field=jss::message)
Return a Json::objectValue with a single entry.
Json::Value make_param_error(std::string const &message)
Returns a new json object that indicates invalid parameters.
Json::Value invalid_field_error(std::string const &name)
Json::Value make_error(error_code_i code)
Returns a new json object that reflects the error code.
static pointer getInstance()