This commit is contained in:
jl777
2019-07-04 03:00:03 -11:00
parent a283a80dc1
commit 7213196954

View File

@@ -134,7 +134,6 @@ int32_t NSPV_rwutxosresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxosres
ptr->utxos = (struct NSPV_utxoresp *)calloc(sizeof(*ptr->utxos),ptr->numutxos); // relies on uint16_t being "small" to prevent mem exhaustion
for (i=0; i<ptr->numutxos; i++)
len += NSPV_rwutxoresp(rwflag,&serialized[len],&ptr->utxos[i]);
fprintf(stderr,"parsed numutxos.%d\n",ptr->numutxos);
}
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->total),&ptr->total);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->interest),&ptr->interest);
@@ -390,7 +389,6 @@ int32_t NSPV_getaddressutxos(struct NSPV_utxosresp *ptr,char *coinaddr) // check
SetCCunspents(unspentOutputs,coinaddr,false);
maxlen = MAX_BLOCK_SIZE(tipheight) - 512;
maxlen /= sizeof(*ptr->utxos);
fprintf(stderr,"getaddressutxos %s\n",coinaddr);
if ( (ptr->numutxos= (int32_t)unspentOutputs.size()) > 0 && ptr->numutxos < maxlen )
{
tipheight = chainActive.LastTip()->GetHeight();
@@ -600,7 +598,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
ind = (int32_t)(sizeof(pfrom->prevtimes)/sizeof(*pfrom->prevtimes)) - 1;
if ( request[0] == NSPV_INFO ) // info
{
//fprintf(stderr,"check info %u vs %u, ind.%d\n",timestamp,pfrom->prevtimes[ind],ind);
fprintf(stderr,"check info %u vs %u, ind.%d\n",timestamp,pfrom->prevtimes[ind],ind);
if ( timestamp > pfrom->prevtimes[ind] )
{
struct NSPV_inforesp I;
@@ -609,9 +607,11 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
{
response.resize(1 + slen);
response[0] = NSPV_INFORESP;
NSPV_rwinforesp(1,&response[1],&I);
pfrom->PushMessage("nSPV",response);
pfrom->prevtimes[ind] = timestamp;
if ( NSPV_rwinforesp(1,&response[1],&I) == slen )
{
pfrom->PushMessage("nSPV",response);
pfrom->prevtimes[ind] = timestamp;
}
NSPV_inforesp_purge(&I);
}
}
@@ -628,7 +628,6 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
memset(&U,0,sizeof(U));
if ( (slen= NSPV_getaddressutxos(&U,coinaddr)) > 0 )
{
printf("getaddressutxos.(%s) slen.%d\n",coinaddr,slen);
response.resize(1 + slen);
response[0] = NSPV_UTXOSRESP;
if ( NSPV_rwutxosresp(1,&response[1],&U) == slen )
@@ -1152,11 +1151,9 @@ void komodo_nSPV(CNode *pto) // polling loop from SendMessages
}*/
if ( timestamp > NSPV_lastinfo + ASSETCHAINS_BLOCKTIME/2 && timestamp > pto->prevtimes[NSPV_INFO>>1] + 2*ASSETCHAINS_BLOCKTIME/3 )
{
if ( (rand() % 100) < 10 ) // randomize which peer to query
{
msg[len++] = NSPV_INFO;
NSPV_req(pto,msg,len,NODE_NSPV,NSPV_INFO>>1);
}
len = 0;
msg[len++] = NSPV_INFO;
NSPV_req(pto,msg,len,NODE_NSPV,NSPV_INFO>>1);
}
}