log low-level network messages only when fDebug is set

This commit is contained in:
Nils Schneider 2011-09-17 18:29:41 +02:00
parent 217208a36d
commit 59090133c0
2 changed files with 12 additions and 7 deletions

View File

@ -1744,9 +1744,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
{ {
static map<unsigned int, vector<unsigned char> > mapReuseKey; static map<unsigned int, vector<unsigned char> > mapReuseKey;
RandAddSeedPerfmon(); RandAddSeedPerfmon();
if (fDebug) if (fDebug) {
printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str()); printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
printf("received: %s (%d bytes)\n", strCommand.c_str(), vRecv.size()); printf("received: %s (%d bytes)\n", strCommand.c_str(), vRecv.size());
}
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
{ {
printf("dropmessagestest DROPPING RECV MESSAGE\n"); printf("dropmessagestest DROPPING RECV MESSAGE\n");
@ -1934,6 +1935,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
pfrom->AddInventoryKnown(inv); pfrom->AddInventoryKnown(inv);
bool fAlreadyHave = AlreadyHave(txdb, inv); bool fAlreadyHave = AlreadyHave(txdb, inv);
if (fDebug)
printf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new"); printf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new");
if (!fAlreadyHave) if (!fAlreadyHave)

View File

@ -282,10 +282,11 @@ public:
nHeaderStart = vSend.size(); nHeaderStart = vSend.size();
vSend << CMessageHeader(pszCommand, 0); vSend << CMessageHeader(pszCommand, 0);
nMessageStart = vSend.size(); nMessageStart = vSend.size();
if (fDebug) if (fDebug) {
printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str()); printf("%s ", DateTimeStrFormat("%x %H:%M:%S", GetTime()).c_str());
printf("sending: %s ", pszCommand); printf("sending: %s ", pszCommand);
} }
}
void AbortMessage() void AbortMessage()
{ {
@ -324,8 +325,10 @@ public:
memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nChecksum), &nChecksum, sizeof(nChecksum)); memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nChecksum), &nChecksum, sizeof(nChecksum));
} }
if (fDebug) {
printf("(%d bytes) ", nSize); printf("(%d bytes) ", nSize);
printf("\n"); printf("\n");
}
nHeaderStart = -1; nHeaderStart = -1;
nMessageStart = -1; nMessageStart = -1;