Browse Source

Merge pull request #520 from tcatm/less-logging

log low-level network messages only when fDebug is set
0.8
Nils Schneider 13 years ago
parent
commit
2d294e080c
  1. 8
      src/main.cpp
  2. 14
      src/net.h

8
src/main.cpp

@ -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,7 +1935,8 @@ 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);
printf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new"); if (fDebug)
printf(" got inventory: %s %s\n", inv.ToString().c_str(), fAlreadyHave ? "have" : "new");
if (!fAlreadyHave) if (!fAlreadyHave)
pfrom->AskFor(inv); pfrom->AskFor(inv);

14
src/net.h

@ -282,9 +282,10 @@ 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()
@ -295,7 +296,9 @@ public:
nHeaderStart = -1; nHeaderStart = -1;
nMessageStart = -1; nMessageStart = -1;
cs_vSend.Leave(); cs_vSend.Leave();
printf("(aborted)\n");
if (fDebug)
printf("(aborted)\n");
} }
void EndMessage() void EndMessage()
@ -324,8 +327,9 @@ public:
memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nChecksum), &nChecksum, sizeof(nChecksum)); memcpy((char*)&vSend[nHeaderStart] + offsetof(CMessageHeader, nChecksum), &nChecksum, sizeof(nChecksum));
} }
printf("(%d bytes) ", nSize); if (fDebug) {
printf("\n"); printf("(%d bytes)\n", nSize);
}
nHeaderStart = -1; nHeaderStart = -1;
nMessageStart = -1; nMessageStart = -1;

Loading…
Cancel
Save