mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
Merge #10189: devtools/net: add a verifier for scriptable changes. Use it to make CNode::id private.
0f3471f
net: make CNode's id private (Cory Fields)9ff0a51
scripted-diff: net: Use accessor rather than node's id directly (Cory Fields)e50c33e
devtools: add script to verify scriptable changes (Cory Fields) Tree-SHA512: a0ff50f4e1d38a2b63109b4996546c91b3e02e00d92c0bf04f48792948f78b1f6d9227a15d25c823fd4723a0277fc6a32c2c1287c7abbb7e50fd82ffb0f8d994
This commit is contained in:
commit
750c5a5b84
@ -43,6 +43,7 @@ install:
|
|||||||
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get update; fi
|
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get update; fi
|
||||||
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq $PACKAGES; fi
|
- if [ -n "$PACKAGES" ]; then travis_retry sudo apt-get install --no-install-recommends --no-upgrade -qq $PACKAGES; fi
|
||||||
before_script:
|
before_script:
|
||||||
|
- if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then contrib/devtools/commit-script-check.sh $TRAVIS_COMMIT_RANGE; fi
|
||||||
- unset CC; unset CXX
|
- unset CC; unset CXX
|
||||||
- if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/check-doc.py; fi
|
- if [ "$CHECK_DOC" = 1 ]; then contrib/devtools/check-doc.py; fi
|
||||||
- mkdir -p depends/SDKs depends/sdk-sources
|
- mkdir -p depends/SDKs depends/sdk-sources
|
||||||
|
39
contrib/devtools/commit-script-check.sh
Executable file
39
contrib/devtools/commit-script-check.sh
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Copyright (c) 2017 The Bitcoin Core developers
|
||||||
|
# Distributed under the MIT software license, see the accompanying
|
||||||
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
# This simple script checks for commits beginning with: scripted-diff:
|
||||||
|
# If found, looks for a script between the lines -BEGIN VERIFY SCRIPT- and
|
||||||
|
# -END VERIFY SCRIPT-. If no ending is found, it reads until the end of the
|
||||||
|
# commit message.
|
||||||
|
|
||||||
|
# The resulting script should exactly transform the previous commit into the current
|
||||||
|
# one. Any remaining diff signals an error.
|
||||||
|
|
||||||
|
if test "x$1" = "x"; then
|
||||||
|
echo "Usage: $0 <commit>..."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
RET=0
|
||||||
|
PREV_BRANCH=`git name-rev --name-only HEAD`
|
||||||
|
PREV_HEAD=`git rev-parse HEAD`
|
||||||
|
for i in `git rev-list --reverse $1`; do
|
||||||
|
git rev-list -n 1 --pretty="%s" $i | grep -q "^scripted-diff:" || continue
|
||||||
|
git checkout --quiet $i^ || exit
|
||||||
|
SCRIPT="`git rev-list --format=%b -n1 $i | sed '/^-BEGIN VERIFY SCRIPT-$/,/^-END VERIFY SCRIPT-$/{//!b};d'`"
|
||||||
|
if test "x$SCRIPT" = "x"; then
|
||||||
|
echo "Error: missing script for: $i"
|
||||||
|
echo "Failed"
|
||||||
|
RET=1
|
||||||
|
else
|
||||||
|
echo "Running script for: $i"
|
||||||
|
echo "$SCRIPT"
|
||||||
|
eval "$SCRIPT"
|
||||||
|
git --no-pager diff --exit-code $i && echo "OK" || (echo "Failed"; false) || RET=1
|
||||||
|
fi
|
||||||
|
git reset --quiet --hard HEAD
|
||||||
|
done
|
||||||
|
git checkout --quiet $PREV_BRANCH 2>/dev/null || git checkout --quiet $PREV_HEAD
|
||||||
|
exit $RET
|
14
src/net.cpp
14
src/net.cpp
@ -948,7 +948,7 @@ bool CConnman::AttemptToEvictConnection()
|
|||||||
continue;
|
continue;
|
||||||
if (node->fDisconnect)
|
if (node->fDisconnect)
|
||||||
continue;
|
continue;
|
||||||
NodeEvictionCandidate candidate = {node->id, node->nTimeConnected, node->nMinPingUsecTime,
|
NodeEvictionCandidate candidate = {node->GetId(), node->nTimeConnected, node->nMinPingUsecTime,
|
||||||
node->nLastBlockTime, node->nLastTXTime,
|
node->nLastBlockTime, node->nLastTXTime,
|
||||||
(node->nServices & nRelevantServices) == nRelevantServices,
|
(node->nServices & nRelevantServices) == nRelevantServices,
|
||||||
node->fRelayTxes, node->pfilter != NULL, node->addr, node->nKeyedNetGroup};
|
node->fRelayTxes, node->pfilter != NULL, node->addr, node->nKeyedNetGroup};
|
||||||
@ -1374,7 +1374,7 @@ void CConnman::ThreadSocketHandler()
|
|||||||
{
|
{
|
||||||
if (pnode->nLastRecv == 0 || pnode->nLastSend == 0)
|
if (pnode->nLastRecv == 0 || pnode->nLastSend == 0)
|
||||||
{
|
{
|
||||||
LogPrint(BCLog::NET, "socket no message in first 60 seconds, %d %d from %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0, pnode->id);
|
LogPrint(BCLog::NET, "socket no message in first 60 seconds, %d %d from %d\n", pnode->nLastRecv != 0, pnode->nLastSend != 0, pnode->GetId());
|
||||||
pnode->fDisconnect = true;
|
pnode->fDisconnect = true;
|
||||||
}
|
}
|
||||||
else if (nTime - pnode->nLastSend > TIMEOUT_INTERVAL)
|
else if (nTime - pnode->nLastSend > TIMEOUT_INTERVAL)
|
||||||
@ -1394,7 +1394,7 @@ void CConnman::ThreadSocketHandler()
|
|||||||
}
|
}
|
||||||
else if (!pnode->fSuccessfullyConnected)
|
else if (!pnode->fSuccessfullyConnected)
|
||||||
{
|
{
|
||||||
LogPrintf("version handshake timeout from %d\n", pnode->id);
|
LogPrintf("version handshake timeout from %d\n", pnode->GetId());
|
||||||
pnode->fDisconnect = true;
|
pnode->fDisconnect = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2487,7 +2487,7 @@ bool CConnman::DisconnectNode(NodeId id)
|
|||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
for(CNode* pnode : vNodes) {
|
for(CNode* pnode : vNodes) {
|
||||||
if (id == pnode->id) {
|
if (id == pnode->GetId()) {
|
||||||
pnode->fDisconnect = true;
|
pnode->fDisconnect = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2625,10 +2625,10 @@ CNode::CNode(NodeId idIn, ServiceFlags nLocalServicesIn, int nMyStartingHeightIn
|
|||||||
nTimeConnected(GetSystemTimeInSeconds()),
|
nTimeConnected(GetSystemTimeInSeconds()),
|
||||||
addr(addrIn),
|
addr(addrIn),
|
||||||
fInbound(fInboundIn),
|
fInbound(fInboundIn),
|
||||||
id(idIn),
|
|
||||||
nKeyedNetGroup(nKeyedNetGroupIn),
|
nKeyedNetGroup(nKeyedNetGroupIn),
|
||||||
addrKnown(5000, 0.001),
|
addrKnown(5000, 0.001),
|
||||||
filterInventoryKnown(50000, 0.000001),
|
filterInventoryKnown(50000, 0.000001),
|
||||||
|
id(idIn),
|
||||||
nLocalHostNonce(nLocalHostNonceIn),
|
nLocalHostNonce(nLocalHostNonceIn),
|
||||||
nLocalServices(nLocalServicesIn),
|
nLocalServices(nLocalServicesIn),
|
||||||
nMyStartingHeight(nMyStartingHeightIn),
|
nMyStartingHeight(nMyStartingHeightIn),
|
||||||
@ -2744,7 +2744,7 @@ void CConnman::PushMessage(CNode* pnode, CSerializedNetMsg&& msg)
|
|||||||
{
|
{
|
||||||
size_t nMessageSize = msg.data.size();
|
size_t nMessageSize = msg.data.size();
|
||||||
size_t nTotalSize = nMessageSize + CMessageHeader::HEADER_SIZE;
|
size_t nTotalSize = nMessageSize + CMessageHeader::HEADER_SIZE;
|
||||||
LogPrint(BCLog::NET, "sending %s (%d bytes) peer=%d\n", SanitizeString(msg.command.c_str()), nMessageSize, pnode->id);
|
LogPrint(BCLog::NET, "sending %s (%d bytes) peer=%d\n", SanitizeString(msg.command.c_str()), nMessageSize, pnode->GetId());
|
||||||
|
|
||||||
std::vector<unsigned char> serializedHeader;
|
std::vector<unsigned char> serializedHeader;
|
||||||
serializedHeader.reserve(CMessageHeader::HEADER_SIZE);
|
serializedHeader.reserve(CMessageHeader::HEADER_SIZE);
|
||||||
@ -2782,7 +2782,7 @@ bool CConnman::ForNode(NodeId id, std::function<bool(CNode* pnode)> func)
|
|||||||
CNode* found = nullptr;
|
CNode* found = nullptr;
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
for (auto&& pnode : vNodes) {
|
for (auto&& pnode : vNodes) {
|
||||||
if(pnode->id == id) {
|
if(pnode->GetId() == id) {
|
||||||
found = pnode;
|
found = pnode;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -611,7 +611,6 @@ public:
|
|||||||
CCriticalSection cs_filter;
|
CCriticalSection cs_filter;
|
||||||
CBloomFilter* pfilter;
|
CBloomFilter* pfilter;
|
||||||
std::atomic<int> nRefCount;
|
std::atomic<int> nRefCount;
|
||||||
const NodeId id;
|
|
||||||
|
|
||||||
const uint64_t nKeyedNetGroup;
|
const uint64_t nKeyedNetGroup;
|
||||||
std::atomic_bool fPauseRecv;
|
std::atomic_bool fPauseRecv;
|
||||||
@ -682,6 +681,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
CNode(const CNode&);
|
CNode(const CNode&);
|
||||||
void operator=(const CNode&);
|
void operator=(const CNode&);
|
||||||
|
const NodeId id;
|
||||||
|
|
||||||
|
|
||||||
const uint64_t nLocalHostNonce;
|
const uint64_t nLocalHostNonce;
|
||||||
|
@ -815,7 +815,7 @@ void PeerLogicValidation::NewPoWValidBlock(const CBlockIndex *pindex, const std:
|
|||||||
!PeerHasHeader(&state, pindex) && PeerHasHeader(&state, pindex->pprev)) {
|
!PeerHasHeader(&state, pindex) && PeerHasHeader(&state, pindex->pprev)) {
|
||||||
|
|
||||||
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", "PeerLogicValidation::NewPoWValidBlock",
|
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", "PeerLogicValidation::NewPoWValidBlock",
|
||||||
hashBlock.ToString(), pnode->id);
|
hashBlock.ToString(), pnode->GetId());
|
||||||
connman->PushMessage(pnode, msgMaker.Make(NetMsgType::CMPCTBLOCK, *pcmpctblock));
|
connman->PushMessage(pnode, msgMaker.Make(NetMsgType::CMPCTBLOCK, *pcmpctblock));
|
||||||
state.pindexBestHeaderSent = pindex;
|
state.pindexBestHeaderSent = pindex;
|
||||||
}
|
}
|
||||||
@ -950,7 +950,7 @@ static void RelayAddress(const CAddress& addr, bool fReachable, CConnman& connma
|
|||||||
|
|
||||||
auto sortfunc = [&best, &hasher, nRelayNodes](CNode* pnode) {
|
auto sortfunc = [&best, &hasher, nRelayNodes](CNode* pnode) {
|
||||||
if (pnode->nVersion >= CADDR_TIME_VERSION) {
|
if (pnode->nVersion >= CADDR_TIME_VERSION) {
|
||||||
uint64_t hashKey = CSipHasher(hasher).Write(pnode->id).Finalize();
|
uint64_t hashKey = CSipHasher(hasher).Write(pnode->GetId()).Finalize();
|
||||||
for (unsigned int i = 0; i < nRelayNodes; i++) {
|
for (unsigned int i = 0; i < nRelayNodes; i++) {
|
||||||
if (hashKey > best[i].first) {
|
if (hashKey > best[i].first) {
|
||||||
std::copy(best.begin() + i, best.begin() + nRelayNodes - 1, best.begin() + i + 1);
|
std::copy(best.begin() + i, best.begin() + nRelayNodes - 1, best.begin() + i + 1);
|
||||||
@ -1176,7 +1176,7 @@ inline void static SendBlockTransactions(const CBlock& block, const BlockTransac
|
|||||||
if (req.indexes[i] >= block.vtx.size()) {
|
if (req.indexes[i] >= block.vtx.size()) {
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
Misbehaving(pfrom->GetId(), 100);
|
Misbehaving(pfrom->GetId(), 100);
|
||||||
LogPrintf("Peer %d sent us a getblocktxn with out-of-bounds tx indices", pfrom->id);
|
LogPrintf("Peer %d sent us a getblocktxn with out-of-bounds tx indices", pfrom->GetId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resp.txn[i] = block.vtx[req.indexes[i]];
|
resp.txn[i] = block.vtx[req.indexes[i]];
|
||||||
@ -1189,7 +1189,7 @@ inline void static SendBlockTransactions(const CBlock& block, const BlockTransac
|
|||||||
|
|
||||||
bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CConnman& connman, const std::atomic<bool>& interruptMsgProc)
|
bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, int64_t nTimeReceived, const CChainParams& chainparams, CConnman& connman, const std::atomic<bool>& interruptMsgProc)
|
||||||
{
|
{
|
||||||
LogPrint(BCLog::NET, "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
|
LogPrint(BCLog::NET, "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->GetId());
|
||||||
if (IsArgSet("-dropmessagestest") && GetRand(GetArg("-dropmessagestest", 0)) == 0)
|
if (IsArgSet("-dropmessagestest") && GetRand(GetArg("-dropmessagestest", 0)) == 0)
|
||||||
{
|
{
|
||||||
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
|
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
|
||||||
@ -1268,7 +1268,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
}
|
}
|
||||||
if (pfrom->nServicesExpected & ~nServices)
|
if (pfrom->nServicesExpected & ~nServices)
|
||||||
{
|
{
|
||||||
LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom->id, nServices, pfrom->nServicesExpected);
|
LogPrint(BCLog::NET, "peer=%d does not offer the expected services (%08x offered, %08x expected); disconnecting\n", pfrom->GetId(), nServices, pfrom->nServicesExpected);
|
||||||
connman.PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_NONSTANDARD,
|
connman.PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_NONSTANDARD,
|
||||||
strprintf("Expected to offer services %08x", pfrom->nServicesExpected)));
|
strprintf("Expected to offer services %08x", pfrom->nServicesExpected)));
|
||||||
pfrom->fDisconnect = true;
|
pfrom->fDisconnect = true;
|
||||||
@ -1278,7 +1278,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
if (nVersion < MIN_PEER_PROTO_VERSION)
|
if (nVersion < MIN_PEER_PROTO_VERSION)
|
||||||
{
|
{
|
||||||
// disconnect from peers older than this proto version
|
// disconnect from peers older than this proto version
|
||||||
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->id, nVersion);
|
LogPrintf("peer=%d using obsolete version %i; disconnecting\n", pfrom->GetId(), nVersion);
|
||||||
connman.PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
|
connman.PushMessage(pfrom, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, strCommand, REJECT_OBSOLETE,
|
||||||
strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)));
|
strprintf("Version must be %d or greater", MIN_PEER_PROTO_VERSION)));
|
||||||
pfrom->fDisconnect = true;
|
pfrom->fDisconnect = true;
|
||||||
@ -1380,7 +1380,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
|
|
||||||
LogPrintf("receive version message: %s: version %d, blocks=%d, us=%s, peer=%d%s\n",
|
LogPrintf("receive version message: %s: version %d, blocks=%d, us=%s, peer=%d%s\n",
|
||||||
cleanSubVer, pfrom->nVersion,
|
cleanSubVer, pfrom->nVersion,
|
||||||
pfrom->nStartingHeight, addrMe.ToString(), pfrom->id,
|
pfrom->nStartingHeight, addrMe.ToString(), pfrom->GetId(),
|
||||||
remoteAddr);
|
remoteAddr);
|
||||||
|
|
||||||
int64_t nTimeOffset = nTime - GetTime();
|
int64_t nTimeOffset = nTime - GetTime();
|
||||||
@ -1562,7 +1562,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool fAlreadyHave = AlreadyHave(inv);
|
bool fAlreadyHave = AlreadyHave(inv);
|
||||||
LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->id);
|
LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom->GetId());
|
||||||
|
|
||||||
if (inv.type == MSG_TX) {
|
if (inv.type == MSG_TX) {
|
||||||
inv.type |= nFetchFlags;
|
inv.type |= nFetchFlags;
|
||||||
@ -1577,14 +1577,14 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
// we now only provide a getheaders response here. When we receive the headers, we will
|
// we now only provide a getheaders response here. When we receive the headers, we will
|
||||||
// then ask for the blocks we need.
|
// then ask for the blocks we need.
|
||||||
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(pindexBestHeader), inv.hash));
|
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(pindexBestHeader), inv.hash));
|
||||||
LogPrint(BCLog::NET, "getheaders (%d) %s to peer=%d\n", pindexBestHeader->nHeight, inv.hash.ToString(), pfrom->id);
|
LogPrint(BCLog::NET, "getheaders (%d) %s to peer=%d\n", pindexBestHeader->nHeight, inv.hash.ToString(), pfrom->GetId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pfrom->AddInventoryKnown(inv);
|
pfrom->AddInventoryKnown(inv);
|
||||||
if (fBlocksOnly) {
|
if (fBlocksOnly) {
|
||||||
LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->id);
|
LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->GetId());
|
||||||
} else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload()) {
|
} else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload()) {
|
||||||
pfrom->AskFor(inv);
|
pfrom->AskFor(inv);
|
||||||
}
|
}
|
||||||
@ -1610,10 +1610,10 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
return error("message getdata size() = %u", vInv.size());
|
return error("message getdata size() = %u", vInv.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
LogPrint(BCLog::NET, "received getdata (%u invsz) peer=%d\n", vInv.size(), pfrom->id);
|
LogPrint(BCLog::NET, "received getdata (%u invsz) peer=%d\n", vInv.size(), pfrom->GetId());
|
||||||
|
|
||||||
if (vInv.size() > 0) {
|
if (vInv.size() > 0) {
|
||||||
LogPrint(BCLog::NET, "received getdata for: %s peer=%d\n", vInv[0].ToString(), pfrom->id);
|
LogPrint(BCLog::NET, "received getdata for: %s peer=%d\n", vInv[0].ToString(), pfrom->GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end());
|
pfrom->vRecvGetData.insert(pfrom->vRecvGetData.end(), vInv.begin(), vInv.end());
|
||||||
@ -1653,7 +1653,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
if (pindex)
|
if (pindex)
|
||||||
pindex = chainActive.Next(pindex);
|
pindex = chainActive.Next(pindex);
|
||||||
int nLimit = 500;
|
int nLimit = 500;
|
||||||
LogPrint(BCLog::NET, "getblocks %d to %s limit %d from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), nLimit, pfrom->id);
|
LogPrint(BCLog::NET, "getblocks %d to %s limit %d from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), nLimit, pfrom->GetId());
|
||||||
for (; pindex; pindex = chainActive.Next(pindex))
|
for (; pindex; pindex = chainActive.Next(pindex))
|
||||||
{
|
{
|
||||||
if (pindex->GetBlockHash() == hashStop)
|
if (pindex->GetBlockHash() == hashStop)
|
||||||
@ -1703,7 +1703,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
|
|
||||||
BlockMap::iterator it = mapBlockIndex.find(req.blockhash);
|
BlockMap::iterator it = mapBlockIndex.find(req.blockhash);
|
||||||
if (it == mapBlockIndex.end() || !(it->second->nStatus & BLOCK_HAVE_DATA)) {
|
if (it == mapBlockIndex.end() || !(it->second->nStatus & BLOCK_HAVE_DATA)) {
|
||||||
LogPrintf("Peer %d sent us a getblocktxn for a block we don't have", pfrom->id);
|
LogPrintf("Peer %d sent us a getblocktxn for a block we don't have", pfrom->GetId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1715,7 +1715,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
// might maliciously send lots of getblocktxn requests to trigger
|
// might maliciously send lots of getblocktxn requests to trigger
|
||||||
// expensive disk reads, because it will require the peer to
|
// expensive disk reads, because it will require the peer to
|
||||||
// actually receive all the data read from disk over the network.
|
// actually receive all the data read from disk over the network.
|
||||||
LogPrint(BCLog::NET, "Peer %d sent us a getblocktxn for a block > %i deep", pfrom->id, MAX_BLOCKTXN_DEPTH);
|
LogPrint(BCLog::NET, "Peer %d sent us a getblocktxn for a block > %i deep", pfrom->GetId(), MAX_BLOCKTXN_DEPTH);
|
||||||
CInv inv;
|
CInv inv;
|
||||||
inv.type = State(pfrom->GetId())->fWantsCmpctWitness ? MSG_WITNESS_BLOCK : MSG_BLOCK;
|
inv.type = State(pfrom->GetId())->fWantsCmpctWitness ? MSG_WITNESS_BLOCK : MSG_BLOCK;
|
||||||
inv.hash = req.blockhash;
|
inv.hash = req.blockhash;
|
||||||
@ -1740,7 +1740,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
if (IsInitialBlockDownload() && !pfrom->fWhitelisted) {
|
if (IsInitialBlockDownload() && !pfrom->fWhitelisted) {
|
||||||
LogPrint(BCLog::NET, "Ignoring getheaders from peer=%d because node is in initial block download\n", pfrom->id);
|
LogPrint(BCLog::NET, "Ignoring getheaders from peer=%d because node is in initial block download\n", pfrom->GetId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1765,7 +1765,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
// we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end
|
// we must use CBlocks, as CBlockHeaders won't include the 0x00 nTx count at the end
|
||||||
std::vector<CBlock> vHeaders;
|
std::vector<CBlock> vHeaders;
|
||||||
int nLimit = MAX_HEADERS_RESULTS;
|
int nLimit = MAX_HEADERS_RESULTS;
|
||||||
LogPrint(BCLog::NET, "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), pfrom->id);
|
LogPrint(BCLog::NET, "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.IsNull() ? "end" : hashStop.ToString(), pfrom->GetId());
|
||||||
for (; pindex; pindex = chainActive.Next(pindex))
|
for (; pindex; pindex = chainActive.Next(pindex))
|
||||||
{
|
{
|
||||||
vHeaders.push_back(pindex->GetBlockHeader());
|
vHeaders.push_back(pindex->GetBlockHeader());
|
||||||
@ -1795,7 +1795,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
// We are in blocks only mode and peer is either not whitelisted or whitelistrelay is off
|
// We are in blocks only mode and peer is either not whitelisted or whitelistrelay is off
|
||||||
if (!fRelayTxes && (!pfrom->fWhitelisted || !GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY)))
|
if (!fRelayTxes && (!pfrom->fWhitelisted || !GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY)))
|
||||||
{
|
{
|
||||||
LogPrint(BCLog::NET, "transaction sent in violation of protocol peer=%d\n", pfrom->id);
|
LogPrint(BCLog::NET, "transaction sent in violation of protocol peer=%d\n", pfrom->GetId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1828,7 +1828,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
pfrom->nLastTXTime = GetTime();
|
pfrom->nLastTXTime = GetTime();
|
||||||
|
|
||||||
LogPrint(BCLog::MEMPOOL, "AcceptToMemoryPool: peer=%d: accepted %s (poolsz %u txn, %u kB)\n",
|
LogPrint(BCLog::MEMPOOL, "AcceptToMemoryPool: peer=%d: accepted %s (poolsz %u txn, %u kB)\n",
|
||||||
pfrom->id,
|
pfrom->GetId(),
|
||||||
tx.GetHash().ToString(),
|
tx.GetHash().ToString(),
|
||||||
mempool.size(), mempool.DynamicMemoryUsage() / 1000);
|
mempool.size(), mempool.DynamicMemoryUsage() / 1000);
|
||||||
|
|
||||||
@ -1948,10 +1948,10 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
// case.
|
// case.
|
||||||
int nDoS = 0;
|
int nDoS = 0;
|
||||||
if (!state.IsInvalid(nDoS) || nDoS == 0) {
|
if (!state.IsInvalid(nDoS) || nDoS == 0) {
|
||||||
LogPrintf("Force relaying tx %s from whitelisted peer=%d\n", tx.GetHash().ToString(), pfrom->id);
|
LogPrintf("Force relaying tx %s from whitelisted peer=%d\n", tx.GetHash().ToString(), pfrom->GetId());
|
||||||
RelayTransaction(tx, connman);
|
RelayTransaction(tx, connman);
|
||||||
} else {
|
} else {
|
||||||
LogPrintf("Not relaying invalid transaction %s from whitelisted peer=%d (%s)\n", tx.GetHash().ToString(), pfrom->id, FormatStateMessage(state));
|
LogPrintf("Not relaying invalid transaction %s from whitelisted peer=%d (%s)\n", tx.GetHash().ToString(), pfrom->GetId(), FormatStateMessage(state));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1963,7 +1963,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
if (state.IsInvalid(nDoS))
|
if (state.IsInvalid(nDoS))
|
||||||
{
|
{
|
||||||
LogPrint(BCLog::MEMPOOLREJ, "%s from peer=%d was not accepted: %s\n", tx.GetHash().ToString(),
|
LogPrint(BCLog::MEMPOOLREJ, "%s from peer=%d was not accepted: %s\n", tx.GetHash().ToString(),
|
||||||
pfrom->id,
|
pfrom->GetId(),
|
||||||
FormatStateMessage(state));
|
FormatStateMessage(state));
|
||||||
if (state.GetRejectCode() > 0 && state.GetRejectCode() < REJECT_INTERNAL) // Never send AcceptToMemoryPool's internal codes over P2P
|
if (state.GetRejectCode() > 0 && state.GetRejectCode() < REJECT_INTERNAL) // Never send AcceptToMemoryPool's internal codes over P2P
|
||||||
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::REJECT, strCommand, (unsigned char)state.GetRejectCode(),
|
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::REJECT, strCommand, (unsigned char)state.GetRejectCode(),
|
||||||
@ -2000,7 +2000,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
Misbehaving(pfrom->GetId(), nDoS);
|
Misbehaving(pfrom->GetId(), nDoS);
|
||||||
}
|
}
|
||||||
LogPrintf("Peer %d sent us invalid header via cmpctblock\n", pfrom->id);
|
LogPrintf("Peer %d sent us invalid header via cmpctblock\n", pfrom->GetId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2079,7 +2079,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
if (status == READ_STATUS_INVALID) {
|
if (status == READ_STATUS_INVALID) {
|
||||||
MarkBlockAsReceived(pindex->GetBlockHash()); // Reset in-flight state in case of whitelist
|
MarkBlockAsReceived(pindex->GetBlockHash()); // Reset in-flight state in case of whitelist
|
||||||
Misbehaving(pfrom->GetId(), 100);
|
Misbehaving(pfrom->GetId(), 100);
|
||||||
LogPrintf("Peer %d sent us invalid compact block\n", pfrom->id);
|
LogPrintf("Peer %d sent us invalid compact block\n", pfrom->GetId());
|
||||||
return true;
|
return true;
|
||||||
} else if (status == READ_STATUS_FAILED) {
|
} else if (status == READ_STATUS_FAILED) {
|
||||||
// Duplicate txindexes, the block is now in-flight, so just request it
|
// Duplicate txindexes, the block is now in-flight, so just request it
|
||||||
@ -2184,7 +2184,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator it = mapBlocksInFlight.find(resp.blockhash);
|
std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator it = mapBlocksInFlight.find(resp.blockhash);
|
||||||
if (it == mapBlocksInFlight.end() || !it->second.second->partialBlock ||
|
if (it == mapBlocksInFlight.end() || !it->second.second->partialBlock ||
|
||||||
it->second.first != pfrom->GetId()) {
|
it->second.first != pfrom->GetId()) {
|
||||||
LogPrint(BCLog::NET, "Peer %d sent us block transactions for block we weren't expecting\n", pfrom->id);
|
LogPrint(BCLog::NET, "Peer %d sent us block transactions for block we weren't expecting\n", pfrom->GetId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2193,7 +2193,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
if (status == READ_STATUS_INVALID) {
|
if (status == READ_STATUS_INVALID) {
|
||||||
MarkBlockAsReceived(resp.blockhash); // Reset in-flight state in case of whitelist
|
MarkBlockAsReceived(resp.blockhash); // Reset in-flight state in case of whitelist
|
||||||
Misbehaving(pfrom->GetId(), 100);
|
Misbehaving(pfrom->GetId(), 100);
|
||||||
LogPrintf("Peer %d sent us invalid compact block/non-matching block transactions\n", pfrom->id);
|
LogPrintf("Peer %d sent us invalid compact block/non-matching block transactions\n", pfrom->GetId());
|
||||||
return true;
|
return true;
|
||||||
} else if (status == READ_STATUS_FAILED) {
|
} else if (status == READ_STATUS_FAILED) {
|
||||||
// Might have collided, fall back to getdata now :(
|
// Might have collided, fall back to getdata now :(
|
||||||
@ -2281,7 +2281,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
headers[0].GetHash().ToString(),
|
headers[0].GetHash().ToString(),
|
||||||
headers[0].hashPrevBlock.ToString(),
|
headers[0].hashPrevBlock.ToString(),
|
||||||
pindexBestHeader->nHeight,
|
pindexBestHeader->nHeight,
|
||||||
pfrom->id, nodestate->nUnconnectingHeaders);
|
pfrom->GetId(), nodestate->nUnconnectingHeaders);
|
||||||
// Set hashLastUnknownBlock for this peer, so that if we
|
// Set hashLastUnknownBlock for this peer, so that if we
|
||||||
// eventually get the headers - even from a different peer -
|
// eventually get the headers - even from a different peer -
|
||||||
// we can use this peer to download.
|
// we can use this peer to download.
|
||||||
@ -2319,7 +2319,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
CNodeState *nodestate = State(pfrom->GetId());
|
CNodeState *nodestate = State(pfrom->GetId());
|
||||||
if (nodestate->nUnconnectingHeaders > 0) {
|
if (nodestate->nUnconnectingHeaders > 0) {
|
||||||
LogPrint(BCLog::NET, "peer=%d: resetting nUnconnectingHeaders (%d -> 0)\n", pfrom->id, nodestate->nUnconnectingHeaders);
|
LogPrint(BCLog::NET, "peer=%d: resetting nUnconnectingHeaders (%d -> 0)\n", pfrom->GetId(), nodestate->nUnconnectingHeaders);
|
||||||
}
|
}
|
||||||
nodestate->nUnconnectingHeaders = 0;
|
nodestate->nUnconnectingHeaders = 0;
|
||||||
|
|
||||||
@ -2330,7 +2330,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
// Headers message had its maximum size; the peer may have more headers.
|
// Headers message had its maximum size; the peer may have more headers.
|
||||||
// TODO: optimize: if pindexLast is an ancestor of chainActive.Tip or pindexBestHeader, continue
|
// TODO: optimize: if pindexLast is an ancestor of chainActive.Tip or pindexBestHeader, continue
|
||||||
// from there instead.
|
// from there instead.
|
||||||
LogPrint(BCLog::NET, "more getheaders (%d) to end to peer=%d (startheight:%d)\n", pindexLast->nHeight, pfrom->id, pfrom->nStartingHeight);
|
LogPrint(BCLog::NET, "more getheaders (%d) to end to peer=%d (startheight:%d)\n", pindexLast->nHeight, pfrom->GetId(), pfrom->nStartingHeight);
|
||||||
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(pindexLast), uint256()));
|
connman.PushMessage(pfrom, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(pindexLast), uint256()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2370,7 +2370,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
|
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
|
||||||
MarkBlockAsInFlight(pfrom->GetId(), pindex->GetBlockHash(), chainparams.GetConsensus(), pindex);
|
MarkBlockAsInFlight(pfrom->GetId(), pindex->GetBlockHash(), chainparams.GetConsensus(), pindex);
|
||||||
LogPrint(BCLog::NET, "Requesting block %s from peer=%d\n",
|
LogPrint(BCLog::NET, "Requesting block %s from peer=%d\n",
|
||||||
pindex->GetBlockHash().ToString(), pfrom->id);
|
pindex->GetBlockHash().ToString(), pfrom->GetId());
|
||||||
}
|
}
|
||||||
if (vGetData.size() > 1) {
|
if (vGetData.size() > 1) {
|
||||||
LogPrint(BCLog::NET, "Downloading blocks toward %s (%d) via headers direct fetch\n",
|
LogPrint(BCLog::NET, "Downloading blocks toward %s (%d) via headers direct fetch\n",
|
||||||
@ -2393,7 +2393,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
|
std::shared_ptr<CBlock> pblock = std::make_shared<CBlock>();
|
||||||
vRecv >> *pblock;
|
vRecv >> *pblock;
|
||||||
|
|
||||||
LogPrint(BCLog::NET, "received block %s peer=%d\n", pblock->GetHash().ToString(), pfrom->id);
|
LogPrint(BCLog::NET, "received block %s peer=%d\n", pblock->GetHash().ToString(), pfrom->GetId());
|
||||||
|
|
||||||
// Process all blocks from whitelisted peers, even if not requested,
|
// Process all blocks from whitelisted peers, even if not requested,
|
||||||
// unless we're still syncing with the network.
|
// unless we're still syncing with the network.
|
||||||
@ -2425,14 +2425,14 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
// Making nodes which are behind NAT and can only make outgoing connections ignore
|
// Making nodes which are behind NAT and can only make outgoing connections ignore
|
||||||
// the getaddr message mitigates the attack.
|
// the getaddr message mitigates the attack.
|
||||||
if (!pfrom->fInbound) {
|
if (!pfrom->fInbound) {
|
||||||
LogPrint(BCLog::NET, "Ignoring \"getaddr\" from outbound connection. peer=%d\n", pfrom->id);
|
LogPrint(BCLog::NET, "Ignoring \"getaddr\" from outbound connection. peer=%d\n", pfrom->GetId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only send one GetAddr response per connection to reduce resource waste
|
// Only send one GetAddr response per connection to reduce resource waste
|
||||||
// and discourage addr stamping of INV announcements.
|
// and discourage addr stamping of INV announcements.
|
||||||
if (pfrom->fSentAddr) {
|
if (pfrom->fSentAddr) {
|
||||||
LogPrint(BCLog::NET, "Ignoring repeated \"getaddr\". peer=%d\n", pfrom->id);
|
LogPrint(BCLog::NET, "Ignoring repeated \"getaddr\". peer=%d\n", pfrom->GetId());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
pfrom->fSentAddr = true;
|
pfrom->fSentAddr = true;
|
||||||
@ -2533,7 +2533,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
|
|
||||||
if (!(sProblem.empty())) {
|
if (!(sProblem.empty())) {
|
||||||
LogPrint(BCLog::NET, "pong peer=%d: %s, %x expected, %x received, %u bytes\n",
|
LogPrint(BCLog::NET, "pong peer=%d: %s, %x expected, %x received, %u bytes\n",
|
||||||
pfrom->id,
|
pfrom->GetId(),
|
||||||
sProblem,
|
sProblem,
|
||||||
pfrom->nPingNonceSent,
|
pfrom->nPingNonceSent,
|
||||||
nonce,
|
nonce,
|
||||||
@ -2610,7 +2610,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
LOCK(pfrom->cs_feeFilter);
|
LOCK(pfrom->cs_feeFilter);
|
||||||
pfrom->minFeeFilter = newFeeFilter;
|
pfrom->minFeeFilter = newFeeFilter;
|
||||||
}
|
}
|
||||||
LogPrint(BCLog::NET, "received: feefilter of %s from peer=%d\n", CFeeRate(newFeeFilter).ToString(), pfrom->id);
|
LogPrint(BCLog::NET, "received: feefilter of %s from peer=%d\n", CFeeRate(newFeeFilter).ToString(), pfrom->GetId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2621,7 +2621,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||||||
|
|
||||||
else {
|
else {
|
||||||
// Ignore unknown commands for extensibility
|
// Ignore unknown commands for extensibility
|
||||||
LogPrint(BCLog::NET, "Unknown command \"%s\" from peer=%d\n", SanitizeString(strCommand), pfrom->id);
|
LogPrint(BCLog::NET, "Unknown command \"%s\" from peer=%d\n", SanitizeString(strCommand), pfrom->GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2701,7 +2701,7 @@ bool ProcessMessages(CNode* pfrom, CConnman& connman, const std::atomic<bool>& i
|
|||||||
msg.SetVersion(pfrom->GetRecvVersion());
|
msg.SetVersion(pfrom->GetRecvVersion());
|
||||||
// Scan for message start
|
// Scan for message start
|
||||||
if (memcmp(msg.hdr.pchMessageStart, chainparams.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) {
|
if (memcmp(msg.hdr.pchMessageStart, chainparams.MessageStart(), CMessageHeader::MESSAGE_START_SIZE) != 0) {
|
||||||
LogPrintf("PROCESSMESSAGE: INVALID MESSAGESTART %s peer=%d\n", SanitizeString(msg.hdr.GetCommand()), pfrom->id);
|
LogPrintf("PROCESSMESSAGE: INVALID MESSAGESTART %s peer=%d\n", SanitizeString(msg.hdr.GetCommand()), pfrom->GetId());
|
||||||
pfrom->fDisconnect = true;
|
pfrom->fDisconnect = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -2710,7 +2710,7 @@ bool ProcessMessages(CNode* pfrom, CConnman& connman, const std::atomic<bool>& i
|
|||||||
CMessageHeader& hdr = msg.hdr;
|
CMessageHeader& hdr = msg.hdr;
|
||||||
if (!hdr.IsValid(chainparams.MessageStart()))
|
if (!hdr.IsValid(chainparams.MessageStart()))
|
||||||
{
|
{
|
||||||
LogPrintf("PROCESSMESSAGE: ERRORS IN HEADER %s peer=%d\n", SanitizeString(hdr.GetCommand()), pfrom->id);
|
LogPrintf("PROCESSMESSAGE: ERRORS IN HEADER %s peer=%d\n", SanitizeString(hdr.GetCommand()), pfrom->GetId());
|
||||||
return fMoreWork;
|
return fMoreWork;
|
||||||
}
|
}
|
||||||
std::string strCommand = hdr.GetCommand();
|
std::string strCommand = hdr.GetCommand();
|
||||||
@ -2770,7 +2770,7 @@ bool ProcessMessages(CNode* pfrom, CConnman& connman, const std::atomic<bool>& i
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!fRet) {
|
if (!fRet) {
|
||||||
LogPrintf("%s(%s, %u bytes) FAILED peer=%d\n", __func__, SanitizeString(strCommand), nMessageSize, pfrom->id);
|
LogPrintf("%s(%s, %u bytes) FAILED peer=%d\n", __func__, SanitizeString(strCommand), nMessageSize, pfrom->GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
@ -2899,7 +2899,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
|||||||
got back an empty response. */
|
got back an empty response. */
|
||||||
if (pindexStart->pprev)
|
if (pindexStart->pprev)
|
||||||
pindexStart = pindexStart->pprev;
|
pindexStart = pindexStart->pprev;
|
||||||
LogPrint(BCLog::NET, "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->nHeight, pto->id, pto->nStartingHeight);
|
LogPrint(BCLog::NET, "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->nHeight, pto->GetId(), pto->nStartingHeight);
|
||||||
connman.PushMessage(pto, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(pindexStart), uint256()));
|
connman.PushMessage(pto, msgMaker.Make(NetMsgType::GETHEADERS, chainActive.GetLocator(pindexStart), uint256()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2929,7 +2929,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
|||||||
(!state.fPreferHeaderAndIDs || pto->vBlockHashesToAnnounce.size() > 1)) ||
|
(!state.fPreferHeaderAndIDs || pto->vBlockHashesToAnnounce.size() > 1)) ||
|
||||||
pto->vBlockHashesToAnnounce.size() > MAX_BLOCKS_TO_ANNOUNCE);
|
pto->vBlockHashesToAnnounce.size() > MAX_BLOCKS_TO_ANNOUNCE);
|
||||||
const CBlockIndex *pBestIndex = NULL; // last header queued for delivery
|
const CBlockIndex *pBestIndex = NULL; // last header queued for delivery
|
||||||
ProcessBlockAvailability(pto->id); // ensure pindexBestKnownBlock is up-to-date
|
ProcessBlockAvailability(pto->GetId()); // ensure pindexBestKnownBlock is up-to-date
|
||||||
|
|
||||||
if (!fRevertToInv) {
|
if (!fRevertToInv) {
|
||||||
bool fFoundStartingHeader = false;
|
bool fFoundStartingHeader = false;
|
||||||
@ -2984,7 +2984,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
|||||||
// We only send up to 1 block as header-and-ids, as otherwise
|
// We only send up to 1 block as header-and-ids, as otherwise
|
||||||
// probably means we're doing an initial-ish-sync or they're slow
|
// probably means we're doing an initial-ish-sync or they're slow
|
||||||
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", __func__,
|
LogPrint(BCLog::NET, "%s sending header-and-ids %s to peer=%d\n", __func__,
|
||||||
vHeaders.front().GetHash().ToString(), pto->id);
|
vHeaders.front().GetHash().ToString(), pto->GetId());
|
||||||
|
|
||||||
int nSendFlags = state.fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
|
int nSendFlags = state.fWantsCmpctWitness ? 0 : SERIALIZE_TRANSACTION_NO_WITNESS;
|
||||||
|
|
||||||
@ -3014,10 +3014,10 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
|||||||
LogPrint(BCLog::NET, "%s: %u headers, range (%s, %s), to peer=%d\n", __func__,
|
LogPrint(BCLog::NET, "%s: %u headers, range (%s, %s), to peer=%d\n", __func__,
|
||||||
vHeaders.size(),
|
vHeaders.size(),
|
||||||
vHeaders.front().GetHash().ToString(),
|
vHeaders.front().GetHash().ToString(),
|
||||||
vHeaders.back().GetHash().ToString(), pto->id);
|
vHeaders.back().GetHash().ToString(), pto->GetId());
|
||||||
} else {
|
} else {
|
||||||
LogPrint(BCLog::NET, "%s: sending header %s to peer=%d\n", __func__,
|
LogPrint(BCLog::NET, "%s: sending header %s to peer=%d\n", __func__,
|
||||||
vHeaders.front().GetHash().ToString(), pto->id);
|
vHeaders.front().GetHash().ToString(), pto->GetId());
|
||||||
}
|
}
|
||||||
connman.PushMessage(pto, msgMaker.Make(NetMsgType::HEADERS, vHeaders));
|
connman.PushMessage(pto, msgMaker.Make(NetMsgType::HEADERS, vHeaders));
|
||||||
state.pindexBestHeaderSent = pBestIndex;
|
state.pindexBestHeaderSent = pBestIndex;
|
||||||
@ -3046,7 +3046,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
|||||||
if (!PeerHasHeader(&state, pindex)) {
|
if (!PeerHasHeader(&state, pindex)) {
|
||||||
pto->PushInventory(CInv(MSG_BLOCK, hashToAnnounce));
|
pto->PushInventory(CInv(MSG_BLOCK, hashToAnnounce));
|
||||||
LogPrint(BCLog::NET, "%s: sending inv peer=%d hash=%s\n", __func__,
|
LogPrint(BCLog::NET, "%s: sending inv peer=%d hash=%s\n", __func__,
|
||||||
pto->id, hashToAnnounce.ToString());
|
pto->GetId(), hashToAnnounce.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3193,7 +3193,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
|||||||
// Stalling only triggers when the block download window cannot move. During normal steady state,
|
// Stalling only triggers when the block download window cannot move. During normal steady state,
|
||||||
// the download window should be much larger than the to-be-downloaded set of blocks, so disconnection
|
// the download window should be much larger than the to-be-downloaded set of blocks, so disconnection
|
||||||
// should only happen during initial block download.
|
// should only happen during initial block download.
|
||||||
LogPrintf("Peer=%d is stalling block download, disconnecting\n", pto->id);
|
LogPrintf("Peer=%d is stalling block download, disconnecting\n", pto->GetId());
|
||||||
pto->fDisconnect = true;
|
pto->fDisconnect = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -3206,7 +3206,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
|||||||
QueuedBlock &queuedBlock = state.vBlocksInFlight.front();
|
QueuedBlock &queuedBlock = state.vBlocksInFlight.front();
|
||||||
int nOtherPeersWithValidatedDownloads = nPeersWithValidatedDownloads - (state.nBlocksInFlightValidHeaders > 0);
|
int nOtherPeersWithValidatedDownloads = nPeersWithValidatedDownloads - (state.nBlocksInFlightValidHeaders > 0);
|
||||||
if (nNow > state.nDownloadingSince + consensusParams.nPowTargetSpacing * (BLOCK_DOWNLOAD_TIMEOUT_BASE + BLOCK_DOWNLOAD_TIMEOUT_PER_PEER * nOtherPeersWithValidatedDownloads)) {
|
if (nNow > state.nDownloadingSince + consensusParams.nPowTargetSpacing * (BLOCK_DOWNLOAD_TIMEOUT_BASE + BLOCK_DOWNLOAD_TIMEOUT_PER_PEER * nOtherPeersWithValidatedDownloads)) {
|
||||||
LogPrintf("Timeout downloading block %s from peer=%d, disconnecting\n", queuedBlock.hash.ToString(), pto->id);
|
LogPrintf("Timeout downloading block %s from peer=%d, disconnecting\n", queuedBlock.hash.ToString(), pto->GetId());
|
||||||
pto->fDisconnect = true;
|
pto->fDisconnect = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -3225,7 +3225,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
|||||||
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
|
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash()));
|
||||||
MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), consensusParams, pindex);
|
MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), consensusParams, pindex);
|
||||||
LogPrint(BCLog::NET, "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(),
|
LogPrint(BCLog::NET, "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(),
|
||||||
pindex->nHeight, pto->id);
|
pindex->nHeight, pto->GetId());
|
||||||
}
|
}
|
||||||
if (state.nBlocksInFlight == 0 && staller != -1) {
|
if (state.nBlocksInFlight == 0 && staller != -1) {
|
||||||
if (State(staller)->nStallingSince == 0) {
|
if (State(staller)->nStallingSince == 0) {
|
||||||
@ -3243,7 +3243,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
|||||||
const CInv& inv = (*pto->mapAskFor.begin()).second;
|
const CInv& inv = (*pto->mapAskFor.begin()).second;
|
||||||
if (!AlreadyHave(inv))
|
if (!AlreadyHave(inv))
|
||||||
{
|
{
|
||||||
LogPrint(BCLog::NET, "Requesting %s peer=%d\n", inv.ToString(), pto->id);
|
LogPrint(BCLog::NET, "Requesting %s peer=%d\n", inv.ToString(), pto->GetId());
|
||||||
vGetData.push_back(inv);
|
vGetData.push_back(inv);
|
||||||
if (vGetData.size() >= 1000)
|
if (vGetData.size() >= 1000)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user