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)
{
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_FOREACH(InfoSub* ispListener, mSubRTTransactions)
{
ispListener->send(jvObj);
ispListener->send(jvObj, true);
}
}
TransactionMetaSet::pointer ret;
@@ -1259,7 +1259,7 @@ void NetworkOPs::pubLedger(Ledger::ref lpAccepted)
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)
{
ispListener->send(jvObj);
ispListener->send(jvObj, true);
}
BOOST_FOREACH(InfoSub* ispListener, mSubRTTransactions)
{
ispListener->send(jvObj);
ispListener->send(jvObj, true);
}
}
theApp->getOrderBookDB().processTxn(stTxn, terResult, meta, jvObj);
@@ -1400,7 +1400,7 @@ void NetworkOPs::pubAccountTransaction(Ledger::ref lpCurrent, const SerializedTr
BOOST_FOREACH(InfoSub* ispListener, notify)
{
ispListener->send(jvObj);
ispListener->send(jvObj, true);
}
}
}

View File

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

View File

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

View File

@@ -85,7 +85,7 @@ void RPCSub::sendThread()
} while (bSend);
}
void RPCSub::send(const Json::Value& jvObj)
void RPCSub::send(const Json::Value& jvObj, bool broadcast)
{
boost::mutex::scoped_lock sl(mLockInfo);
@@ -96,7 +96,7 @@ void RPCSub::send(const Json::Value& jvObj)
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));

View File

@@ -35,7 +35,7 @@ public:
virtual ~RPCSub() { ; }
// 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)
{

View File

@@ -72,11 +72,11 @@ public:
}
// 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();
if (ptr)
mHandler->send(ptr, jvObj);
mHandler->send(ptr, jvObj, broadcast);
}
// 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
{
cLog(lsDEBUG) << "Ws:: Sending '" << strMessage << "'";
cLog(broadcast ? lsTRACE : lsDEBUG) << "Ws:: Sending '" << 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;
// cLog(lsDEBUG) << "Ws:: Object '" << jfwWriter.write(jvObj) << "'";
send(cpClient, jfwWriter.write(jvObj));
send(cpClient, jfwWriter.write(jvObj), broadcast);
}
void pingTimer(connection_ptr cpClient)
@@ -177,7 +177,7 @@ public:
jvResult["type"] = "error";
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())
{
@@ -187,7 +187,7 @@ public:
jvResult["error"] = "jsonInvalid"; // Received invalid json.
jvResult["value"] = mpMessage->get_payload();
send(cpClient, jvResult);
send(cpClient, jvResult, false);
}
else
{
@@ -200,7 +200,7 @@ public:
return;
conn = it->second;
}
send(cpClient, conn->invokeCommand(jvRequest));
send(cpClient, conn->invokeCommand(jvRequest), false);
}
}