19
src/main.cpp
19
src/main.cpp
@@ -49,6 +49,7 @@ using namespace std;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
CCriticalSection cs_main;
|
CCriticalSection cs_main;
|
||||||
|
extern uint8_t NOTARY_PUBKEY33[33];
|
||||||
|
|
||||||
BlockMap mapBlockIndex;
|
BlockMap mapBlockIndex;
|
||||||
CChain chainActive;
|
CChain chainActive;
|
||||||
@@ -4494,7 +4495,14 @@ void static ProcessGetData(CNode* pfrom)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (inv.type == MSG_BLOCK)
|
if (inv.type == MSG_BLOCK)
|
||||||
|
{
|
||||||
|
//uint256 hash; int32_t z;
|
||||||
|
//hash = block.GetHash();
|
||||||
|
//for (z=31; z>=0; z--)
|
||||||
|
// fprintf(stderr,"%02x",((uint8_t *)&hash)[z]);
|
||||||
|
//fprintf(stderr," send block %d\n",komodo_block2height(&block));
|
||||||
pfrom->PushMessage("block", block);
|
pfrom->PushMessage("block", block);
|
||||||
|
}
|
||||||
else // MSG_FILTERED_BLOCK)
|
else // MSG_FILTERED_BLOCK)
|
||||||
{
|
{
|
||||||
LOCK(pfrom->cs_filter);
|
LOCK(pfrom->cs_filter);
|
||||||
@@ -4583,6 +4591,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
|
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
|
||||||
|
//fprintf(stderr, "recv: %s peer=%d\n", SanitizeString(strCommand).c_str(), (int32_t)pfrom->GetId());
|
||||||
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
|
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
|
||||||
{
|
{
|
||||||
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
|
LogPrintf("dropmessagestest DROPPING RECV MESSAGE\n");
|
||||||
@@ -4956,6 +4965,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
vector<CBlock> vHeaders;
|
vector<CBlock> vHeaders;
|
||||||
int nLimit = MAX_HEADERS_RESULTS;
|
int nLimit = MAX_HEADERS_RESULTS;
|
||||||
LogPrint("net", "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString(), pfrom->id);
|
LogPrint("net", "getheaders %d to %s from peer=%d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString(), pfrom->id);
|
||||||
|
if ( pfrom->lasthdrsreq >= chainActive.Height()-MAX_HEADERS_RESULTS || pfrom->lasthdrsreq != (int32_t)(pindex ? pindex->nHeight : -1) )
|
||||||
|
{
|
||||||
|
pfrom->lasthdrsreq = (int32_t)(pindex ? pindex->nHeight : -1);
|
||||||
for (; pindex; pindex = chainActive.Next(pindex))
|
for (; pindex; pindex = chainActive.Next(pindex))
|
||||||
{
|
{
|
||||||
vHeaders.push_back(pindex->GetBlockHeader());
|
vHeaders.push_back(pindex->GetBlockHeader());
|
||||||
@@ -4964,6 +4976,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
}
|
}
|
||||||
pfrom->PushMessage("headers", vHeaders);
|
pfrom->PushMessage("headers", vHeaders);
|
||||||
}
|
}
|
||||||
|
else if ( NOTARY_PUBKEY33[0] != 0 )
|
||||||
|
fprintf(stderr,"you can ignore redundant getheaders from peer.%d %d prev.%d\n",(int32_t)pfrom->id,(int32_t)(pindex ? pindex->nHeight : -1),pfrom->lasthdrsreq);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
else if (strCommand == "tx")
|
else if (strCommand == "tx")
|
||||||
@@ -5143,9 +5158,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
// 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.
|
||||||
|
if ( pfrom->sendhdrsreq >= chainActive.Height()-MAX_HEADERS_RESULTS || pindexLast->nHeight != pfrom->sendhdrsreq )
|
||||||
|
{
|
||||||
|
pfrom->sendhdrsreq = (int32_t)pindexLast->nHeight;
|
||||||
LogPrint("net", "more getheaders (%d) to end to peer=%d (startheight:%d)\n", pindexLast->nHeight, pfrom->id, pfrom->nStartingHeight);
|
LogPrint("net", "more getheaders (%d) to end to peer=%d (startheight:%d)\n", pindexLast->nHeight, pfrom->id, pfrom->nStartingHeight);
|
||||||
pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexLast), uint256());
|
pfrom->PushMessage("getheaders", chainActive.GetLocator(pindexLast), uint256());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CheckBlockIndex();
|
CheckBlockIndex();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -264,6 +264,7 @@ public:
|
|||||||
std::string addrName;
|
std::string addrName;
|
||||||
CService addrLocal;
|
CService addrLocal;
|
||||||
int nVersion;
|
int nVersion;
|
||||||
|
int lasthdrsreq,sendhdrsreq;
|
||||||
// strSubVer is whatever byte array we read from the wire. However, this field is intended
|
// strSubVer is whatever byte array we read from the wire. However, this field is intended
|
||||||
// to be printed out, displayed to humans in various forms and so on. So we sanitize it and
|
// to be printed out, displayed to humans in various forms and so on. So we sanitize it and
|
||||||
// store the sanitized version in cleanSubVer. The original should be used when dealing with
|
// store the sanitized version in cleanSubVer. The original should be used when dealing with
|
||||||
|
|||||||
Reference in New Issue
Block a user