Merge pull request #1596 from jl777/jl777

Jl777
This commit is contained in:
jl777
2019-07-09 02:09:49 -11:00
committed by GitHub
7 changed files with 27 additions and 13 deletions

View File

@@ -1147,9 +1147,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// Option to startup with mocktime set (used for regression testing): // Option to startup with mocktime set (used for regression testing):
SetMockTime(GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op SetMockTime(GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op
if (GetBoolArg("-peerbloomfilters", true)) if ( KOMODO_NSPV == 0 )
nLocalServices |= NODE_BLOOM; {
if (GetBoolArg("-peerbloomfilters", true))
nLocalServices |= NODE_BLOOM;
}
nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE); nMaxTipAge = GetArg("-maxtipage", DEFAULT_MAX_TIP_AGE);
#ifdef ENABLE_MINING #ifdef ENABLE_MINING

View File

@@ -23,6 +23,7 @@
// CC signing // CC signing
// make sure to sanity check all vector lengths on receipt // make sure to sanity check all vector lengths on receipt
// make sure no files are updated (this is to allow nSPV=1 and later nSPV=0 without affecting database) // make sure no files are updated (this is to allow nSPV=1 and later nSPV=0 without affecting database)
// bug: under load, fullnode was returning all 0 nServices
#ifndef KOMODO_NSPV_H #ifndef KOMODO_NSPV_H
#define KOMODO_NSPV_H #define KOMODO_NSPV_H

View File

@@ -210,12 +210,17 @@ int32_t NSPV_sendrawtransaction(struct NSPV_broadcastresp *ptr,uint8_t *data,int
{ {
LOCK(cs_main); LOCK(cs_main);
ptr->txid = tx.GetHash(); ptr->txid = tx.GetHash();
fprintf(stderr,"addmempool transaction %s\n",ptr->txid.GetHex().c_str()); fprintf(stderr,"try to addmempool transaction %s\n",ptr->txid.GetHex().c_str());
if ( myAddtomempool(tx) != 0 ) if ( myAddtomempool(tx) != 0 )
{
int32_t i;
for (i=0; i<n; i++)
fprintf(stderr,"%02x",data[i]);
fprintf(stderr," relay transaction %s retcode.%d\n",ptr->txid.GetHex().c_str(),ptr->retcode);
ptr->retcode = 1; ptr->retcode = 1;
else ptr->retcode = 0; RelayTransaction(tx);
//fprintf(stderr,"relay transaction %s retcode.%d\n",ptr->txid.GetHex().c_str(),ptr->retcode); } else ptr->retcode = -3;
RelayTransaction(tx);
} else ptr->retcode = -1; } else ptr->retcode = -1;
return(sizeof(*ptr)); return(sizeof(*ptr));
} }

View File

@@ -102,6 +102,8 @@ void komodo_nSPVresp(CNode *pfrom,std::vector<uint8_t> response) // received a r
CNode *NSPV_req(CNode *pnode,uint8_t *msg,int32_t len,uint64_t mask,int32_t ind) CNode *NSPV_req(CNode *pnode,uint8_t *msg,int32_t len,uint64_t mask,int32_t ind)
{ {
int32_t n,flag = 0; CNode *pnodes[64]; uint32_t timestamp = (uint32_t)time(NULL); int32_t n,flag = 0; CNode *pnodes[64]; uint32_t timestamp = (uint32_t)time(NULL);
//if ( KOMODO_NSPV == 0 )
// return(0);
if ( pnode == 0 ) if ( pnode == 0 )
{ {
memset(pnodes,0,sizeof(pnodes)); memset(pnodes,0,sizeof(pnodes));
@@ -129,7 +131,8 @@ CNode *NSPV_req(CNode *pnode,uint8_t *msg,int32_t len,uint64_t mask,int32_t ind)
std::vector<uint8_t> request; std::vector<uint8_t> request;
request.resize(len); request.resize(len);
memcpy(&request[0],msg,len); memcpy(&request[0],msg,len);
//fprintf(stderr,"pushmessage [%d] len.%d\n",msg[0],len); if ( KOMODO_NSPV == 0 )
fprintf(stderr,"pushmessage [%d] len.%d\n",msg[0],len);
pnode->PushMessage("getnSPV",request); pnode->PushMessage("getnSPV",request);
pnode->prevtimes[ind] = timestamp; pnode->prevtimes[ind] = timestamp;
return(pnode); return(pnode);

View File

@@ -132,7 +132,7 @@ bool NSPV_SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const C
fprintf(stderr,"%02x",((uint8_t *)&scriptPubKey)[i]); fprintf(stderr,"%02x",((uint8_t *)&scriptPubKey)[i]);
fprintf(stderr," scriptPubKey\n"); fprintf(stderr," scriptPubKey\n");
} }
if ( nTime < KOMODO_SAPLING_ACTIVATION ) if ( nTime != 0 && nTime < KOMODO_SAPLING_ACTIVATION )
{ {
fprintf(stderr,"use legacy sig validation\n"); fprintf(stderr,"use legacy sig validation\n");
branchid = 0; branchid = 0;

View File

@@ -3974,7 +3974,8 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
void FlushStateToDisk() { void FlushStateToDisk() {
CValidationState state; CValidationState state;
FlushStateToDisk(state, FLUSH_STATE_ALWAYS); if ( KOMODO_NSPV == 0 )
FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
} }
void PruneAndFlush() { void PruneAndFlush() {
@@ -7247,7 +7248,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
{ {
if ( (pfrom->nServices & NODE_NSPV) == 0 ) if ( (pfrom->nServices & NODE_NSPV) == 0 )
{ {
//fprintf(stderr,"invalid nSPV peer.%d\n",pfrom->id); // fprintf(stderr,"invalid nServices.%llx nSPV peer.%d\n",(long long)pfrom->nServices,pfrom->id);
pfrom->fDisconnect = true; pfrom->fDisconnect = true;
return false; return false;
} }

View File

@@ -444,6 +444,8 @@ void CNode::CloseSocketDisconnect()
vRecvMsg.clear(); vRecvMsg.clear();
} }
extern int32_t KOMODO_NSPV;
void CNode::PushVersion() void CNode::PushVersion()
{ {
int nBestHeight = g_signals.GetHeight().get_value_or(0); int nBestHeight = g_signals.GetHeight().get_value_or(0);
@@ -458,7 +460,7 @@ void CNode::PushVersion()
LogPrint("net", "send version message: version %d, blocks=%d, us=%s, peer=%d\n", PROTOCOL_VERSION, nBestHeight, addrMe.ToString(), id); 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, PushMessage("version", PROTOCOL_VERSION, nLocalServices, nTime, addrYou, addrMe,
nLocalHostNonce, strSubVersion, nBestHeight, true); nLocalHostNonce, strSubVersion, nBestHeight, true);
//fprintf(stderr,"PUSH services.%llx\n",(long long)nLocalServices); //fprintf(stderr,"KOMODO_NSPV.%d PUSH services.%llx\n",KOMODO_NSPV,(long long)nLocalServices);
} }
@@ -1841,7 +1843,7 @@ bool StopNode()
for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++) for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++)
semOutbound->post(); semOutbound->post();
if (fAddressesInitialized) if (KOMODO_NSPV == 0 && fAddressesInitialized)
{ {
DumpAddresses(); DumpAddresses();
fAddressesInitialized = false; fAddressesInitialized = false;