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/impl/Handler.h>
28 #include <ripple/rpc/ShardArchiveHandler.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))
81 for (
auto& it : context.
params[jss::shards])
84 if (!it.isMember(jss::index))
86 auto& jv {it[jss::index]};
87 if (!(jv.isUInt() || (jv.isInt() && jv.asInt() >= 0)))
94 if (!it.isMember(jss::url))
97 auto unparsedURL = it[jss::url].asString();
103 if (url.
scheme !=
"https")
108 if (archiveName.empty() || archiveName.size() <= ext.size())
111 std::string(jss::url) +
"', invalid archive name");
113 if (!boost::iends_with(archiveName, ext))
116 std::string(jss::url) +
"', invalid archive extension");
120 if (!archives.
emplace(jv.asUInt(),
124 std::string(jss::index) +
"', duplicate shard ids.");
140 "Failed to create ShardArchiveHandler.");
144 "Failed to initiate ShardArchiveHandler.");
153 for (
auto& [index, url] : archives)
155 if (!handler->add(index, std::move(url)))
164 if (!handler->start())
171 preShards = shardStore->getPreShards();
172 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()