Order book subscribe cleanups.

This commit is contained in:
JoelKatz
2014-01-08 14:31:00 -08:00
committed by Vinnie Falco
parent 93e03804d0
commit d474d68566
4 changed files with 12 additions and 9 deletions

View File

@@ -210,6 +210,7 @@ BookListeners::pointer OrderBookDB::makeBookListeners (RippleCurrency const& cur
mListeners [RippleBookRef (
RippleAssetRef (currencyPays, issuerPays),
RippleAssetRef (currencyGets, issuerGets))] = ret;
assert (getBookListeners (currencyPays, currencyGets, issuerPays, issuerGets) == ret);
}
return ret;
@@ -228,12 +229,12 @@ BookListeners::pointer OrderBookDB::getBookListeners (RippleCurrency const& curr
if (it0 != mListeners.end ())
ret = it0->second;
return ret;;
return ret;
}
// Based on the meta, send the meta to the streams that are listening
// We need to determine which streams a given meta effects
void OrderBookDB::processTxn (Ledger::ref ledger, const AcceptedLedgerTx& alTx, Json::Value& jvObj)
void OrderBookDB::processTxn (Ledger::ref ledger, const AcceptedLedgerTx& alTx, Json::Value const& jvObj)
{
ScopedLockType sl (mLock, __FILE__, __LINE__);
@@ -249,6 +250,7 @@ void OrderBookDB::processTxn (Ledger::ref ledger, const AcceptedLedgerTx& alTx,
{
SField* field = NULL;
// We need a field that contains the TakerGets and TakerPays parameters
if (node.getFName () == sfModifiedNode)
{
field = &sfPreviousFields;
@@ -313,7 +315,7 @@ void BookListeners::removeSubscriber (uint64 seq)
mListeners.erase (seq);
}
void BookListeners::publish (Json::Value& jvObj)
void BookListeners::publish (Json::Value const& jvObj)
{
Json::FastWriter jfwWriter;
std::string sObj = jfwWriter.write (jvObj);

View File

@@ -29,7 +29,7 @@ public:
BookListeners ();
void addSubscriber (InfoSub::ref sub);
void removeSubscriber (uint64 sub);
void publish (Json::Value& jvObj);
void publish (Json::Value const& jvObj);
private:
typedef RippleRecursiveMutex LockType;
@@ -73,7 +73,7 @@ public:
RippleIssuer const& issuerPays, RippleIssuer const& issuerGets);
// see if this txn effects any orderbook
void processTxn (Ledger::ref ledger, const AcceptedLedgerTx& alTx, Json::Value& jvObj);
void processTxn (Ledger::ref ledger, const AcceptedLedgerTx& alTx, Json::Value const& jvObj);
private:
// by ci/ii

View File

@@ -2609,6 +2609,7 @@ bool NetworkOPsImp::subBook (InfoSub::ref isrListener, RippleCurrency const& cur
BookListeners::pointer listeners =
getApp().getOrderBookDB ().makeBookListeners (currencyPays, currencyGets, issuerPays, issuerGets);
assert (listeners);
if (listeners)
listeners->addSubscriber (isrListener);

View File

@@ -3530,10 +3530,10 @@ Json::Value RPCHandler::doSubscribe (Json::Value params, Resource::Charge& loadT
|| !jvSubRequest["taker_gets"].isObject ())
return rpcError (rpcINVALID_PARAMS);
uint160 uTakerPaysCurrencyID;
uint160 uTakerPaysIssuerID;
uint160 uTakerGetsCurrencyID;
uint160 uTakerGetsIssuerID;
RippleCurrency uTakerPaysCurrencyID;
RippleIssuer uTakerPaysIssuerID;
RippleCurrency uTakerGetsCurrencyID;
RippleIssuer uTakerGetsIssuerID;
bool bBoth = (jvSubRequest.isMember ("both") && jvSubRequest["both"].asBool ())
|| (jvSubRequest.isMember ("both_sides") && jvSubRequest["both_sides"].asBool ()); // DEPRECATED
bool bSnapshot = (jvSubRequest.isMember ("snapshot") && jvSubRequest["snapshot"].asBool ())