Track whether a message is a broadcast. If a broadcast, log at a lower level.

This commit is contained in:
JoelKatz
2013-02-12 22:05:46 -08:00
parent 1cf14d68be
commit 73fe72bfa3
7 changed files with 20 additions and 20 deletions

View File

@@ -1026,7 +1026,7 @@ void NetworkOPs::pubServer()
BOOST_FOREACH(InfoSub* ispListener, mSubServer) BOOST_FOREACH(InfoSub* ispListener, mSubServer)
{ {
ispListener->send(jvObj); ispListener->send(jvObj, true);
} }
} }
} }
@@ -1228,7 +1228,7 @@ void NetworkOPs::pubProposedTransaction(Ledger::ref lpCurrent, const SerializedT
boost::recursive_mutex::scoped_lock sl(mMonitorLock); boost::recursive_mutex::scoped_lock sl(mMonitorLock);
BOOST_FOREACH(InfoSub* ispListener, mSubRTTransactions) BOOST_FOREACH(InfoSub* ispListener, mSubRTTransactions)
{ {
ispListener->send(jvObj); ispListener->send(jvObj, true);
} }
} }
TransactionMetaSet::pointer ret; TransactionMetaSet::pointer ret;
@@ -1259,7 +1259,7 @@ void NetworkOPs::pubLedger(Ledger::ref lpAccepted)
BOOST_FOREACH(InfoSub* ispListener, mSubLedger) BOOST_FOREACH(InfoSub* ispListener, mSubLedger)
{ {
ispListener->send(jvObj); ispListener->send(jvObj, true);
} }
} }
} }
@@ -1333,12 +1333,12 @@ void NetworkOPs::pubAcceptedTransaction(Ledger::ref lpCurrent, const SerializedT
BOOST_FOREACH(InfoSub* ispListener, mSubTransactions) BOOST_FOREACH(InfoSub* ispListener, mSubTransactions)
{ {
ispListener->send(jvObj); ispListener->send(jvObj, true);
} }
BOOST_FOREACH(InfoSub* ispListener, mSubRTTransactions) BOOST_FOREACH(InfoSub* ispListener, mSubRTTransactions)
{ {
ispListener->send(jvObj); ispListener->send(jvObj, true);
} }
} }
theApp->getOrderBookDB().processTxn(stTxn, terResult, meta, jvObj); theApp->getOrderBookDB().processTxn(stTxn, terResult, meta, jvObj);
@@ -1400,7 +1400,7 @@ void NetworkOPs::pubAccountTransaction(Ledger::ref lpCurrent, const SerializedTr
BOOST_FOREACH(InfoSub* ispListener, notify) BOOST_FOREACH(InfoSub* ispListener, notify)
{ {
ispListener->send(jvObj); ispListener->send(jvObj, true);
} }
} }
} }

View File

@@ -36,7 +36,7 @@ public:
virtual ~InfoSub(); virtual ~InfoSub();
virtual void send(const Json::Value& jvObj) = 0; virtual void send(const Json::Value& jvObj, bool broadcast) = 0;
void onSendEmpty(); void onSendEmpty();

View File

@@ -229,7 +229,7 @@ void BookListeners::publish(Json::Value& jvObj)
BOOST_FOREACH(InfoSub* sub,mListeners) BOOST_FOREACH(InfoSub* sub,mListeners)
{ {
sub->send(jvObj); sub->send(jvObj, true);
} }
} }

View File

@@ -85,7 +85,7 @@ void RPCSub::sendThread()
} while (bSend); } while (bSend);
} }
void RPCSub::send(const Json::Value& jvObj) void RPCSub::send(const Json::Value& jvObj, bool broadcast)
{ {
boost::mutex::scoped_lock sl(mLockInfo); boost::mutex::scoped_lock sl(mLockInfo);
@@ -96,7 +96,7 @@ void RPCSub::send(const Json::Value& jvObj)
mDeque.pop_back(); mDeque.pop_back();
} }
cLog(lsINFO) << boost::str(boost::format("callRPC push: %s") % jvObj); cLog(broadcast ? lsDEBUG : lsINFO) << boost::str(boost::format("callRPC push: %s") % jvObj);
mDeque.push_back(std::make_pair(mSeq++, jvObj)); mDeque.push_back(std::make_pair(mSeq++, jvObj));

View File

@@ -35,7 +35,7 @@ public:
virtual ~RPCSub() { ; } virtual ~RPCSub() { ; }
// Implement overridden functions from base class: // Implement overridden functions from base class:
void send(const Json::Value& jvObj); void send(const Json::Value& jvObj, bool broadcast);
void setUsername(const std::string& strUsername) void setUsername(const std::string& strUsername)
{ {

View File

@@ -72,11 +72,11 @@ public:
} }
// Implement overridden functions from base class: // Implement overridden functions from base class:
void send(const Json::Value& jvObj) void send(const Json::Value& jvObj, bool broadcast)
{ {
connection_ptr ptr = mConnection.lock(); connection_ptr ptr = mConnection.lock();
if (ptr) if (ptr)
mHandler->send(ptr, jvObj); mHandler->send(ptr, jvObj, broadcast);
} }
// Utilities // Utilities

View File

@@ -61,11 +61,11 @@ public:
} }
} }
void send(connection_ptr cpClient, const std::string& strMessage) void send(connection_ptr cpClient, const std::string& strMessage, bool broadcast)
{ {
try try
{ {
cLog(lsDEBUG) << "Ws:: Sending '" << strMessage << "'"; cLog(broadcast ? lsTRACE : lsDEBUG) << "Ws:: Sending '" << strMessage << "'";
cpClient->send(strMessage); cpClient->send(strMessage);
} }
@@ -75,13 +75,13 @@ public:
} }
} }
void send(connection_ptr cpClient, const Json::Value& jvObj) void send(connection_ptr cpClient, const Json::Value& jvObj, bool broadcast)
{ {
Json::FastWriter jfwWriter; Json::FastWriter jfwWriter;
// cLog(lsDEBUG) << "Ws:: Object '" << jfwWriter.write(jvObj) << "'"; // cLog(lsDEBUG) << "Ws:: Object '" << jfwWriter.write(jvObj) << "'";
send(cpClient, jfwWriter.write(jvObj)); send(cpClient, jfwWriter.write(jvObj), broadcast);
} }
void pingTimer(connection_ptr cpClient) void pingTimer(connection_ptr cpClient)
@@ -177,7 +177,7 @@ public:
jvResult["type"] = "error"; jvResult["type"] = "error";
jvResult["error"] = "wsTextRequired"; // We only accept text messages. jvResult["error"] = "wsTextRequired"; // We only accept text messages.
send(cpClient, jvResult); send(cpClient, jvResult, false);
} }
else if (!jrReader.parse(mpMessage->get_payload(), jvRequest) || jvRequest.isNull() || !jvRequest.isObject()) else if (!jrReader.parse(mpMessage->get_payload(), jvRequest) || jvRequest.isNull() || !jvRequest.isObject())
{ {
@@ -187,7 +187,7 @@ public:
jvResult["error"] = "jsonInvalid"; // Received invalid json. jvResult["error"] = "jsonInvalid"; // Received invalid json.
jvResult["value"] = mpMessage->get_payload(); jvResult["value"] = mpMessage->get_payload();
send(cpClient, jvResult); send(cpClient, jvResult, false);
} }
else else
{ {
@@ -200,7 +200,7 @@ public:
return; return;
conn = it->second; conn = it->second;
} }
send(cpClient, conn->invokeCommand(jvRequest)); send(cpClient, conn->invokeCommand(jvRequest), false);
} }
} }