Merge pull request #3764
2e36866
Show nodeid instead of addresses (for anonymity) unless otherwise requested. (R E Broadley)
This commit is contained in:
commit
00fa78c35b
6 changed files with 35 additions and 25 deletions
|
@ -290,6 +290,7 @@ std::string HelpMessage(HelpMessageMode mode)
|
|||
strUsage += " -gen " + _("Generate coins (default: 0)") + "\n";
|
||||
strUsage += " -genproclimit=<n> " + _("Set the processor limit for when generation is on (-1 = unlimited, default: -1)") + "\n";
|
||||
strUsage += " -help-debug " + _("Show all debugging options (usage: --help -help-debug)") + "\n";
|
||||
strUsage += " -logips " + _("Include IP addresses in debug output (default: 0)") + "\n";
|
||||
strUsage += " -logtimestamps " + _("Prepend debug output with timestamp (default: 1)") + "\n";
|
||||
if (GetBoolArg("-help-debug", false))
|
||||
{
|
||||
|
@ -586,6 +587,7 @@ bool AppInit2(boost::thread_group& threadGroup)
|
|||
fServer = GetBoolArg("-server", false);
|
||||
fPrintToConsole = GetBoolArg("-printtoconsole", false);
|
||||
fLogTimestamps = GetBoolArg("-logtimestamps", true);
|
||||
fLogIPs = GetBoolArg("-logips", false);
|
||||
setvbuf(stdout, NULL, _IOLBF, 0);
|
||||
#ifdef ENABLE_WALLET
|
||||
bool fDisableWallet = GetBoolArg("-disablewallet", false);
|
||||
|
|
34
src/main.cpp
34
src/main.cpp
|
@ -3538,7 +3538,7 @@ void static ProcessGetData(CNode* pfrom)
|
|||
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
||||
{
|
||||
RandAddSeedPerfmon();
|
||||
LogPrint("net", "received: %s (%u bytes)\n", strCommand, vRecv.size());
|
||||
LogPrint("net", "received: %s (%u bytes) peer=%d\n", strCommand, vRecv.size(), pfrom->id);
|
||||
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
|
||||
{
|
||||
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
|
||||
|
@ -3570,7 +3570,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||
if (pfrom->nVersion < MIN_PEER_PROTO_VERSION)
|
||||
{
|
||||
// disconnect from peers older than this proto version
|
||||
LogPrintf("partner %s using obsolete version %i; disconnecting\n", pfrom->addr.ToString(), pfrom->nVersion);
|
||||
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, pfrom->nVersion);
|
||||
pfrom->PushMessage("reject", strCommand, REJECT_OBSOLETE,
|
||||
strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION));
|
||||
pfrom->fDisconnect = true;
|
||||
|
@ -3651,7 +3651,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||
|
||||
pfrom->fSuccessfullyConnected = true;
|
||||
|
||||
LogPrintf("receive version message: %s: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", pfrom->cleanSubVer, pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString(), addrFrom.ToString(), pfrom->addr.ToString());
|
||||
LogPrintf("receive version message: %s: version %d, blocks=%d, us=%s, peer=%d\n", pfrom->cleanSubVer, pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString(), pfrom->id);
|
||||
|
||||
AddTimeData(pfrom->addr, nTime);
|
||||
}
|
||||
|
@ -3758,7 +3758,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||
pfrom->AddInventoryKnown(inv);
|
||||
|
||||
bool fAlreadyHave = AlreadyHave(inv);
|
||||
LogPrint("net", " got inventory: %s %s\n", inv.ToString(), fAlreadyHave ? "have" : "new");
|
||||
LogPrint("net", "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id);
|
||||
|
||||
if (!fAlreadyHave) {
|
||||
if (!fImporting && !fReindex) {
|
||||
|
@ -3791,10 +3791,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||
}
|
||||
|
||||
if (fDebug || (vInv.size() != 1))
|
||||
LogPrint("net", "received getdata (%u invsz)\n", vInv.size());
|
||||
LogPrint("net", "received getdata (%u invsz) peer=%d\n", vInv.size(), pfrom->id);
|
||||
|
||||
if ((fDebug && vInv.size() > 0) || (vInv.size() == 1))
|
||||
LogPrint("net", "received getdata for: %s\n", vInv[0].ToString());
|
||||
LogPrint("net", "received getdata for: %s peer=%d\n", vInv[0].ToString(), pfrom->id);
|
||||
|
||||
pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end());
|
||||
ProcessGetData(pfrom);
|
||||
|
@ -3816,7 +3816,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||
if (pindex)
|
||||
pindex = chainActive.Next(pindex);
|
||||
int nLimit = 500;
|
||||
LogPrint("net", "getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop==uint256(0) ? "end" : hashStop.ToString(), nLimit);
|
||||
LogPrint("net", "getblocks %d to %s limit %d from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop==uint256(0) ? "end" : hashStop.ToString(), nLimit, pfrom->id);
|
||||
for (; pindex; pindex = chainActive.Next(pindex))
|
||||
{
|
||||
if (pindex->GetBlockHash() == hashStop)
|
||||
|
@ -3899,8 +3899,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||
vEraseQueue.push_back(inv.hash);
|
||||
|
||||
|
||||
LogPrint("mempool", "AcceptToMemoryPool: %s %s : accepted %s (poolsz %u)\n",
|
||||
pfrom->addr.ToString(), pfrom->cleanSubVer,
|
||||
LogPrint("mempool", "AcceptToMemoryPool: peer=%d %s : accepted %s (poolsz %u)\n",
|
||||
pfrom->id, pfrom->cleanSubVer,
|
||||
tx.GetHash().ToString(),
|
||||
mempool.mapTx.size());
|
||||
|
||||
|
@ -3953,8 +3953,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||
int nDoS = 0;
|
||||
if (state.IsInvalid(nDoS))
|
||||
{
|
||||
LogPrint("mempool", "%s from %s %s was not accepted into the memory pool: %s\n", tx.GetHash().ToString(),
|
||||
pfrom->addr.ToString(), pfrom->cleanSubVer,
|
||||
LogPrint("mempool", "%s from peer=%d %s was not accepted into the memory pool: %s\n", tx.GetHash().ToString(),
|
||||
pfrom->id, pfrom->cleanSubVer,
|
||||
state.GetRejectReason());
|
||||
pfrom->PushMessage("reject", strCommand, state.GetRejectCode(),
|
||||
state.GetRejectReason(), inv.hash);
|
||||
|
@ -3969,7 +3969,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||
CBlock block;
|
||||
vRecv >> block;
|
||||
|
||||
LogPrint("net", "received block %s\n", block.GetHash().ToString());
|
||||
LogPrint("net", "received block %s peer=%d\n", block.GetHash().ToString(), pfrom->id);
|
||||
// block.print();
|
||||
|
||||
CInv inv(MSG_BLOCK, block.GetHash());
|
||||
|
@ -4086,8 +4086,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv)
|
|||
}
|
||||
|
||||
if (!(sProblem.empty())) {
|
||||
LogPrint("net", "pong %s %s: %s, %x expected, %x received, %u bytes\n",
|
||||
pfrom->addr.ToString(),
|
||||
LogPrint("net", "pong peer=%d %s: %s, %x expected, %x received, %u bytes\n",
|
||||
pfrom->id,
|
||||
pfrom->cleanSubVer,
|
||||
sProblem,
|
||||
pfrom->nPingNonceSent,
|
||||
|
@ -4327,7 +4327,7 @@ bool ProcessMessages(CNode* pfrom)
|
|||
}
|
||||
|
||||
if (!fRet)
|
||||
LogPrintf("ProcessMessage(%s, %u bytes) FAILED\n", strCommand, nMessageSize);
|
||||
LogPrintf("ProcessMessage(%s, %u bytes) FAILED peer=%d\n", strCommand, nMessageSize, pfrom->id);
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -4531,7 +4531,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||
uint256 hash = state.vBlocksToDownload.front();
|
||||
vGetData.push_back(CInv(MSG_BLOCK, hash));
|
||||
MarkBlockAsInFlight(pto->GetId(), hash);
|
||||
LogPrint("net", "Requesting block %s from %s\n", hash.ToString(), state.name);
|
||||
LogPrint("net", "Requesting block %s peer=%d\n", hash.ToString(), pto->id);
|
||||
if (vGetData.size() >= 1000)
|
||||
{
|
||||
pto->PushMessage("getdata", vGetData);
|
||||
|
@ -4548,7 +4548,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
|||
if (!AlreadyHave(inv))
|
||||
{
|
||||
if (fDebug)
|
||||
LogPrint("net", "sending getdata: %s\n", inv.ToString());
|
||||
LogPrint("net", "Requesting %s peer=%d\n", inv.ToString(), pto->id);
|
||||
vGetData.push_back(inv);
|
||||
if (vGetData.size() >= 1000)
|
||||
{
|
||||
|
|
13
src/net.cpp
13
src/net.cpp
|
@ -491,8 +491,6 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
|
|||
{
|
||||
addrman.Attempt(addrConnect);
|
||||
|
||||
LogPrint("net", "connected %s\n", pszDest ? pszDest : addrConnect.ToString());
|
||||
|
||||
// Set to non-blocking
|
||||
#ifdef WIN32
|
||||
u_long nOne = 1;
|
||||
|
@ -513,6 +511,7 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
|
|||
}
|
||||
|
||||
pnode->nTimeConnected = GetTime();
|
||||
|
||||
return pnode;
|
||||
}
|
||||
|
||||
|
@ -524,7 +523,7 @@ void CNode::CloseSocketDisconnect()
|
|||
fDisconnect = true;
|
||||
if (hSocket != INVALID_SOCKET)
|
||||
{
|
||||
LogPrint("net", "disconnecting node %s\n", addrName);
|
||||
LogPrint("net", "disconnecting peer=%d\n", id);
|
||||
closesocket(hSocket);
|
||||
hSocket = INVALID_SOCKET;
|
||||
}
|
||||
|
@ -548,7 +547,10 @@ void CNode::PushVersion()
|
|||
CAddress addrYou = (addr.IsRoutable() && !IsProxy(addr) ? addr : CAddress(CService("0.0.0.0",0)));
|
||||
CAddress addrMe = GetLocalAddress(&addr);
|
||||
RAND_bytes((unsigned char*)&nLocalHostNonce, sizeof(nLocalHostNonce));
|
||||
LogPrint("net", "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), addrYou.ToString(), addr.ToString());
|
||||
if (fLogIPs)
|
||||
LogPrint("net", "send version message: version %d, blocks=%d, us=%s, them=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), addrYou.ToString(), id);
|
||||
else
|
||||
LogPrint("net", "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), id);
|
||||
PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
|
||||
nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector<string>()), nBestHeight, true);
|
||||
}
|
||||
|
@ -950,7 +952,6 @@ void ThreadSocketHandler()
|
|||
}
|
||||
else
|
||||
{
|
||||
LogPrint("net", "accepted connection %s\n", addr.ToString());
|
||||
CNode* pnode = new CNode(hSocket, addr, "", true);
|
||||
pnode->AddRef();
|
||||
|
||||
|
@ -1040,7 +1041,7 @@ void ThreadSocketHandler()
|
|||
{
|
||||
if (pnode->nLastRecv == 0 || pnode->nLastSend == 0)
|
||||
{
|
||||
LogPrint("net", "socket no message in first 60 seconds, %d %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0);
|
||||
LogPrint("net", "socket no message in first 60 seconds, %d %d from %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0, pnode->id);
|
||||
pnode->fDisconnect = true;
|
||||
}
|
||||
else if (nTime - pnode->nLastSend > TIMEOUT_INTERVAL)
|
||||
|
|
|
@ -330,6 +330,11 @@ public:
|
|||
id = nLastNodeId++;
|
||||
}
|
||||
|
||||
if (fLogIPs)
|
||||
LogPrint("net", "Added connection to %s peer=%d\n", addrName, id);
|
||||
else
|
||||
LogPrint("net", "Added connection peer=%d\n", id);
|
||||
|
||||
// Be shy and don't send version until we hear
|
||||
if (hSocket != INVALID_SOCKET && !fInbound)
|
||||
PushVersion();
|
||||
|
@ -446,7 +451,7 @@ public:
|
|||
nRequestTime = it->second;
|
||||
else
|
||||
nRequestTime = 0;
|
||||
LogPrint("net", "askfor %s %d (%s)\n", inv.ToString(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str());
|
||||
LogPrint("net", "askfor %s %d (%s) peer=%d\n", inv.ToString(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str(), id);
|
||||
|
||||
// Make sure not to reuse time indexes to keep things in the same order
|
||||
int64_t nNow = GetTimeMicros() - 1000000;
|
||||
|
@ -514,7 +519,7 @@ public:
|
|||
assert(ssSend.size () >= CMessageHeader::CHECKSUM_OFFSET + sizeof(nChecksum));
|
||||
memcpy((char*)&ssSend[CMessageHeader::CHECKSUM_OFFSET], &nChecksum, sizeof(nChecksum));
|
||||
|
||||
LogPrint("net", "(%d bytes)\n", nSize);
|
||||
LogPrint("net", "(%d bytes) peer=%d\n", nSize, id);
|
||||
|
||||
std::deque<CSerializeData>::iterator it = vSendMsg.insert(vSendMsg.end(), CSerializeData());
|
||||
ssSend.GetAndClear(*it);
|
||||
|
|
|
@ -95,6 +95,7 @@ bool fDaemon = false;
|
|||
bool fServer = false;
|
||||
string strMiscWarning;
|
||||
bool fLogTimestamps = false;
|
||||
bool fLogIPs = false;
|
||||
volatile bool fReopenDebugLog = false;
|
||||
CClientUIInterface uiInterface;
|
||||
|
||||
|
|
|
@ -100,6 +100,7 @@ extern bool fPrintToDebugLog;
|
|||
extern bool fServer;
|
||||
extern std::string strMiscWarning;
|
||||
extern bool fLogTimestamps;
|
||||
extern bool fLogIPs;
|
||||
extern volatile bool fReopenDebugLog;
|
||||
|
||||
void RandAddSeed();
|
||||
|
|
Loading…
Reference in a new issue