1#include <xrpld/rpc/Context.h>
2#include <xrpld/rpc/Role.h>
3#include <xrpld/rpc/detail/RPCHelpers.h>
5#include <xrpl/basics/Log.h>
6#include <xrpl/basics/base_uint.h>
7#include <xrpl/json/json_value.h>
8#include <xrpl/protocol/AccountID.h>
9#include <xrpl/protocol/Book.h>
10#include <xrpl/protocol/ErrorCodes.h>
11#include <xrpl/protocol/RPCErr.h>
12#include <xrpl/protocol/jss.h>
13#include <xrpl/server/InfoSub.h>
14#include <xrpl/server/NetworkOPs.h>
25 bool removeUrl{
false};
54 for (
auto& it : context.
params[jss::streams])
60 if (streamName ==
"server")
64 else if (streamName ==
"ledger")
68 else if (streamName ==
"manifests")
72 else if (streamName ==
"transactions")
77 streamName ==
"transactions_proposed" ||
78 streamName ==
"rt_transactions")
82 else if (streamName ==
"validations")
86 else if (streamName ==
"peer_status")
90 else if (streamName ==
"consensus")
101 auto accountsProposed = context.
params.
isMember(jss::accounts_proposed)
102 ? jss::accounts_proposed
128 auto const& req = context.
params[jss::account_history_tx_stream];
129 if (!req.isMember(jss::account) || !req[jss::account].isString())
136 bool stopHistoryOnly =
false;
137 if (req.isMember(jss::stop_history_tx_only))
139 if (!req[jss::stop_history_tx_only].isBool())
141 stopHistoryOnly = req[jss::stop_history_tx_only].asBool();
145 JLOG(context.
j.
debug()) <<
"doUnsubscribe: account_history_tx_stream: " <<
toBase58(*
id)
146 <<
" stopHistoryOnly=" << (stopHistoryOnly ?
"true" :
"false");
154 for (
auto& jv : context.
params[jss::books])
156 if (!jv.isObject() || !jv.isMember(jss::taker_pays) || !jv.isMember(jss::taker_gets) ||
157 !jv[jss::taker_pays].isObjectOrNull() || !jv[jss::taker_gets].isObjectOrNull())
172 if (book.in == book.out)
174 JLOG(context.
j.
info()) <<
"taker_gets same as taker_pays.";
178 if (jv.isMember(jss::domain))
181 if (!jv[jss::domain].isString() || !domain.
parseHex(jv[jss::domain].asString()))
186 book.domain = domain;
192 <<
"doUnsubscribe: book not subscribed (no-op for seq=" << ispSub->
getSeq()
197 if ((jv.isMember(jss::both) && jv[jss::both].asBool()) ||
198 (jv.isMember(jss::both_sides) && jv[jss::both_sides].asBool()))
203 <<
"doUnsubscribe: reversed book not subscribed (no-op for seq="
204 << ispSub->
getSeq() <<
")";
std::string asString() const
Returns the unquoted string value.
bool isMember(char const *key) const
Return true if the object has a member named key.
constexpr bool parseHex(std::string_view sv)
Parse a hex string into a base_uint.
virtual bool unsubRTTransactions(std::uint64_t uListener)=0
virtual bool unsubConsensus(std::uint64_t uListener)=0
virtual bool unsubTransactions(std::uint64_t uListener)=0
virtual bool unsubServer(std::uint64_t uListener)=0
virtual bool tryRemoveRpcSub(std::string const &strUrl)=0
virtual void unsubAccountHistory(ref ispListener, AccountID const &account, bool historyOnly)=0
unsubscribe an account's transactions
virtual bool unsubBook(ref ispListener, Book const &)=0
Remove a book subscription for a live subscriber.
virtual bool unsubLedger(std::uint64_t uListener)=0
virtual bool unsubPeerStatus(std::uint64_t uListener)=0
virtual bool unsubManifests(std::uint64_t uListener)=0
virtual bool unsubValidations(std::uint64_t uListener)=0
virtual pointer findRpcSub(std::string const &strUrl)=0
virtual void unsubAccount(ref isplistener, hash_set< AccountID > const &vnaAccountIDs, bool realTime)=0
std::shared_ptr< InfoSub > pointer
std::uint64_t getSeq() const
@ Object
object value (collection of name/value pairs).
hash_set< AccountID > parseAccountIds(json::Value const &jvArray)
Parses an array of account IDs from a JSON value.
ErrorCodeI parseSubUnsubJson(Asset &asset, json::Value const ¶ms, json::StaticString const &name, beast::Journal j)
Parse subscribe/unsubscribe parameters.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::optional< AccountID > parseBase58(std::string const &s)
Parse AccountID from checked, base58 string.
std::string toBase58(AccountID const &v)
Convert AccountID to base58 checked string.
json::Value rpcError(ErrorCodeI iError)
Book reversed(Book const &book)
json::Value doUnsubscribe(RPC::JsonContext &)