From 165c26660917e563282b1a6720fd1511bf02442f Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 3 Jul 2019 22:06:43 -1100 Subject: [PATCH] Test --- src/komodo_nSPV.h | 11 ++++++++--- src/main.cpp | 23 ++++++++++++++++++----- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index 5114dc999..2305e445a 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -756,9 +756,9 @@ CNode *NSPV_req(CNode *pnode,uint8_t *msg,int32_t len,uint32_t mask,int32_t ind) if ( pnode != 0 ) { std::vector request; - request.resize(len+1); + request.resize(len); memcpy(&request[0],msg,len); - fprintf(stderr,"pushmessage len.%d\n",len); + fprintf(stderr,"pushmessage [%d] len.%d\n",msg[0],len); pnode->PushMessage("getnSPV",request); pnode->prevtimes[ind] = timestamp; return(pnode); @@ -902,8 +902,13 @@ UniValue NSPV_addressutxos(char *coinaddr) result.push_back(Pair("error","invalid address")); return(result); } - if ( NSPV_utxosresult.nodeheight < NSPV_inforesult.height ) + if ( NSPV_inforesult.height == 0 || NSPV_utxosresult.nodeheight < NSPV_inforesult.height ) { + if ( NSPV_inforesult.height == 0 ) + { + msg[0] = NSPV_INFO; + NSPV_req(0,msg,1,NODE_NSPV,NSPV_INFO>>1); + } slen = (int32_t)strlen(coinaddr); msg[len++] = NSPV_UTXOS; msg[len++] = slen; diff --git a/src/main.cpp b/src/main.cpp index 4438aa08e..334d1f276 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7052,7 +7052,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, { const CChainParams& chainparams = Params(); LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id); - if ( KOMODO_NSPV != 0 ) + //if ( KOMODO_NSPV != 0 ) + if ( strCommand != "version" && strCommand != "verack" ) fprintf(stderr, "recv: %s peer=%d\n", SanitizeString(strCommand).c_str(), (int32_t)pfrom->GetId()); if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) { @@ -7226,11 +7227,23 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, { pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); - if ( KOMODO_NSPV != 0 && (pfrom->nServices & NODE_NSPV) == 0 ) + if ( KOMODO_NSPV != 0 ) { - fprintf(stderr,"invalid nSPV peer.%d\n",pfrom->id); - pfrom->fDisconnect = true; - return false; + if ( (pfrom->nServices & NODE_NSPV) == 0 ) + { + fprintf(stderr,"invalid nSPV peer.%d\n",pfrom->id); + pfrom->fDisconnect = true; + return false; + } + } + else + { + if ( pfrom->nServices != 0 ) + { + fprintf(stderr,"debug mode, disconnect legacy peer.%d\n",pfrom->id); + pfrom->fDisconnect = true; + return false; + } } // Mark this node as currently connected, so we update its timestamp later. if (pfrom->fNetworkNode) {