From 7c6f471173acfe851e4ac7c60636b9d29687f8fc Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 5 Jul 2019 06:57:09 -1100 Subject: [PATCH] Allow "inv" to be sent from superlite client --- src/main.cpp | 57 +++++++++++++++++++------------------- src/net.cpp | 3 -- src/rpc/rawtransaction.cpp | 1 - 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 23f0acbce..5407c9e91 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -8243,35 +8243,35 @@ bool SendMessages(CNode* pto, bool fSendTrickle) state.fShouldBan = false; } komodo_nSPV(pto); - if ( KOMODO_NSPV != 0 ) - return(true); - BOOST_FOREACH(const CBlockReject& reject, state.rejects) - pto->PushMessage("reject", (string)"block", reject.chRejectCode, reject.strRejectReason, reject.hashBlock); - state.rejects.clear(); - - // Start block sync - if (pindexBestHeader == NULL) - pindexBestHeader = chainActive.Tip(); - bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do. - if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex && pindexBestHeader!=0) { - // Only actively request headers from a single peer, unless we're close to today. - if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { - state.fSyncStarted = true; - nSyncStarted++; - CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; - LogPrint("net", "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->GetHeight(), pto->id, pto->nStartingHeight); - pto->PushMessage("getheaders", chainActive.GetLocator(pindexStart), uint256()); + if ( KOMODO_NSPV == 0 ) + { + BOOST_FOREACH(const CBlockReject& reject, state.rejects) + pto->PushMessage("reject", (string)"block", reject.chRejectCode, reject.strRejectReason, reject.hashBlock); + state.rejects.clear(); + + // Start block sync + if (pindexBestHeader == NULL) + pindexBestHeader = chainActive.Tip(); + bool fFetch = state.fPreferredDownload || (nPreferredDownload == 0 && !pto->fClient && !pto->fOneShot); // Download if this is a nice peer, or we have no nice peers and this one might do. + if (!state.fSyncStarted && !pto->fClient && !fImporting && !fReindex && pindexBestHeader!=0) { + // Only actively request headers from a single peer, unless we're close to today. + if ((nSyncStarted == 0 && fFetch) || pindexBestHeader->GetBlockTime() > GetAdjustedTime() - 24 * 60 * 60) { + state.fSyncStarted = true; + nSyncStarted++; + CBlockIndex *pindexStart = pindexBestHeader->pprev ? pindexBestHeader->pprev : pindexBestHeader; + LogPrint("net", "initial getheaders (%d) to peer=%d (startheight:%d)\n", pindexStart->GetHeight(), pto->id, pto->nStartingHeight); + pto->PushMessage("getheaders", chainActive.GetLocator(pindexStart), uint256()); + } + } + + // Resend wallet transactions that haven't gotten in a block yet + // Except during reindex, importing and IBD, when old wallet + // transactions become unconfirmed and spams other nodes. + if (!fReindex && !fImporting && !IsInitialBlockDownload()) + { + GetMainSignals().Broadcast(nTimeBestReceived); } } - - // Resend wallet transactions that haven't gotten in a block yet - // Except during reindex, importing and IBD, when old wallet - // transactions become unconfirmed and spams other nodes. - if (!fReindex && !fImporting && !IsInitialBlockDownload()) - { - GetMainSignals().Broadcast(nTimeBestReceived); - } - // // Message: inventory // @@ -8319,7 +8319,8 @@ bool SendMessages(CNode* pto, bool fSendTrickle) } if (!vInv.empty()) pto->PushMessage("inv", vInv); - + if ( KOMODO_NSPV != 0 ) + return(true); // Detect whether we're stalling int64_t nNow = GetTimeMicros(); if (!pto->fDisconnect && state.nStallingSince && state.nStallingSince < nNow - 1000000 * BLOCK_STALLING_TIMEOUT) { diff --git a/src/net.cpp b/src/net.cpp index f3f763694..0586d7124 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -1897,7 +1897,6 @@ void RelayTransaction(const CTransaction& tx) void RelayTransaction(const CTransaction& tx, const CDataStream& ss) { - fprintf(stderr,"RelayTransaction\n"); CInv inv(MSG_TX, tx.GetHash()); { LOCK(cs_mapRelay); @@ -1915,10 +1914,8 @@ void RelayTransaction(const CTransaction& tx, const CDataStream& ss) LOCK(cs_vNodes); BOOST_FOREACH(CNode* pnode, vNodes) { - fprintf(stderr,"pnode relay tx.%d\n",(int32_t)pnode->fRelayTxes); if(!pnode->fRelayTxes) continue; - fprintf(stderr,"found pnode\n"); LOCK(pnode->cs_filter); if (pnode->pfilter) { diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index d60f0c52e..09247d311 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -1342,7 +1342,6 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp) } } RelayTransaction(tx); - return hashTx.GetHex(); }