20 #include <ripple/app/main/Application.h>
21 #include <ripple/app/misc/NetworkOPs.h>
22 #include <ripple/app/ledger/LedgerMaster.h>
23 #include <ripple/basics/Log.h>
24 #include <ripple/ledger/ReadView.h>
25 #include <ripple/net/RPCErr.h>
26 #include <ripple/net/RPCSub.h>
27 #include <ripple/protocol/ErrorCodes.h>
28 #include <ripple/protocol/jss.h>
29 #include <ripple/resource/Fees.h>
30 #include <ripple/rpc/impl/RPCHelpers.h>
31 #include <ripple/rpc/Context.h>
32 #include <ripple/rpc/Role.h>
44 JLOG(context.
j.
info()) <<
"doSubscribe: RPC subscribe requires a url";
71 <<
"doSubscribe: building: " << strUrl;
76 strUrl, strUsername, strPassword, context.
app.
logs ());
78 strUrl, std::dynamic_pointer_cast<InfoSub> (rspSub));
88 <<
"doSubscribe: reusing: " << strUrl;
90 if (
auto rpcSub = std::dynamic_pointer_cast<RPCSub> (ispSub))
96 rpcSub->setUsername (strUsername);
99 rpcSub->setPassword (strPassword);
112 JLOG (context.
j.
info())
113 <<
"doSubscribe: streams requires an array.";
117 for (
auto const& it: context.
params[jss::streams])
123 if (streamName ==
"server")
128 else if (streamName ==
"ledger")
132 else if (streamName ==
"manifests")
136 else if (streamName ==
"transactions")
140 else if (streamName ==
"transactions_proposed" ||
141 streamName ==
"rt_transactions")
145 else if (streamName ==
"validations")
149 else if (streamName ==
"peer_status")
155 else if (streamName ==
"consensus")
166 auto accountsProposed = context.
params.
isMember(jss::accounts_proposed)
167 ? jss::accounts_proposed : jss::rt_accounts;
188 JLOG(context.
j.
debug()) <<
"doSubscribe: accounts: " << ids.size();
196 for (
auto& j: context.
params[jss::books])
199 || !j.isMember (jss::taker_pays)
200 || !j.isMember (jss::taker_gets)
201 || !j[jss::taker_pays].isObjectOrNull ()
202 || !j[jss::taker_gets].isObjectOrNull ())
213 JLOG (context.
j.
info()) <<
"Bad taker_pays currency.";
218 if (((taker_pays.
isMember (jss::issuer))
219 && (! taker_pays[jss::issuer].
isString ()
221 taker_pays[jss::issuer].
asString ())))
226 JLOG (context.
j.
info()) <<
"Bad taker_pays issuer.";
234 JLOG (context.
j.
info()) <<
"Bad taker_gets currency.";
239 if (((taker_gets.
isMember (jss::issuer))
240 && (!taker_gets[jss::issuer].
isString ()
242 taker_gets[jss::issuer].
asString ())))
247 JLOG (context.
j.
info()) <<
"Bad taker_gets issuer.";
254 JLOG (context.
j.
info())
255 <<
"taker_gets same as taker_pays.";
259 boost::optional<AccountID> takerID;
261 if (j.isMember (jss::taker))
263 takerID = parseBase58<AccountID>(
264 j[jss::taker].asString());
271 JLOG (context.
j.
warn()) <<
"Bad market: " << book;
279 (j.isMember(jss::both) && j[jss::both].asBool()) ||
280 (j.isMember(jss::both_sides) && j[jss::both_sides].asBool());
286 if ((j.isMember(jss::snapshot) && j[jss::snapshot].asBool()) ||
287 (j.isMember(jss::state_now) && j[jss::state_now].asBool()))
301 field == jss::asks ?
reversed (book) : book,
309 for (
auto const& e : jvOffers[jss::offers])
314 jvResult[field] = jvOffers[jss::offers];
bool to_currency(Currency ¤cy, std::string const &code)
Tries to convert a string to a Currency, returns true on success.
std::shared_ptr< ReadView const > getPublishedLedger()
bool isConsistent(Book const &book)
Stream trace() const
Severity stream access functions.
const Charge feeMediumBurdenRPC
Resource::Charge & loadType
virtual bool subValidations(ref ispListener)=0
virtual bool subRTTransactions(ref ispListener)=0
virtual bool subTransactions(ref ispListener)=0
static constexpr LimitRange bookOffers
Limits for the book_offers command.
virtual NetworkOPs & getOPs()=0
virtual bool subBook(ref ispListener, Book const &)=0
virtual pointer findRpcSub(std::string const &strUrl)=0
virtual bool subManifests(ref ispListener)=0
Value & append(const Value &value)
Append value to array at the end.
@ objectValue
object value (collection of name/value pairs).
virtual LedgerMaster & getLedgerMaster()=0
virtual bool subLedger(ref ispListener, Json::Value &jvResult)=0
virtual void getBookPage(std::shared_ptr< ReadView const > &lpLedger, Book const &book, AccountID const &uTakerID, bool const bProof, unsigned int iLimit, Json::Value const &jvMarker, Json::Value &jvResult)=0
Book reversed(Book const &book)
virtual JobQueue & getJobQueue()=0
virtual pointer addRpcSub(std::string const &strUrl, ref rspEntry)=0
bool isMember(const char *key) const
Return true if the object has a member named key.
Json::Value rpcError(int iError, Json::Value jvResult)
std::shared_ptr< RPCSub > make_RPCSub(InfoSub::Source &source, boost::asio::io_service &io_service, JobQueue &jobQueue, std::string const &strUrl, std::string const &strUsername, std::string const &strPassword, Logs &logs)
virtual boost::asio::io_service & getIOService()=0
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Lightweight wrapper to tag static string.
virtual bool subConsensus(ref ispListener)=0
hash_set< AccountID > parseAccountIds(Json::Value const &jvArray)
virtual bool subPeerStatus(ref ispListener)=0
Json::Value make_param_error(std::string const &message)
Returns a new json object that indicates invalid parameters.
virtual bool subServer(ref ispListener, Json::Value &jvResult, bool admin)=0
virtual void subAccount(ref ispListener, hash_set< AccountID > const &vnaAccountIDs, bool realTime)=0
AccountID const & noAccount()
A placeholder for empty accounts.
bool to_issuer(AccountID &, std::string const &)
Convert hex or base58 string to AccountID.
std::string asString() const
Returns the unquoted string value.
Json::Value doSubscribe(RPC::JsonContext &)