+pront
This commit is contained in:
@@ -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
|
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++)
|
for (i=0; i<ptr->numutxos; i++)
|
||||||
len += NSPV_rwutxoresp(rwflag,&serialized[len],&ptr->utxos[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->total),&ptr->total);
|
||||||
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->interest),&ptr->interest);
|
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);
|
SetCCunspents(unspentOutputs,coinaddr,false);
|
||||||
maxlen = MAX_BLOCK_SIZE(tipheight) - 512;
|
maxlen = MAX_BLOCK_SIZE(tipheight) - 512;
|
||||||
maxlen /= sizeof(*ptr->utxos);
|
maxlen /= sizeof(*ptr->utxos);
|
||||||
fprintf(stderr,"getaddressutxos %s\n",coinaddr);
|
|
||||||
if ( (ptr->numutxos= (int32_t)unspentOutputs.size()) > 0 && ptr->numutxos < maxlen )
|
if ( (ptr->numutxos= (int32_t)unspentOutputs.size()) > 0 && ptr->numutxos < maxlen )
|
||||||
{
|
{
|
||||||
tipheight = chainActive.LastTip()->GetHeight();
|
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;
|
ind = (int32_t)(sizeof(pfrom->prevtimes)/sizeof(*pfrom->prevtimes)) - 1;
|
||||||
if ( request[0] == NSPV_INFO ) // info
|
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] )
|
if ( timestamp > pfrom->prevtimes[ind] )
|
||||||
{
|
{
|
||||||
struct NSPV_inforesp I;
|
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.resize(1 + slen);
|
||||||
response[0] = NSPV_INFORESP;
|
response[0] = NSPV_INFORESP;
|
||||||
NSPV_rwinforesp(1,&response[1],&I);
|
if ( NSPV_rwinforesp(1,&response[1],&I) == slen )
|
||||||
pfrom->PushMessage("nSPV",response);
|
{
|
||||||
pfrom->prevtimes[ind] = timestamp;
|
pfrom->PushMessage("nSPV",response);
|
||||||
|
pfrom->prevtimes[ind] = timestamp;
|
||||||
|
}
|
||||||
NSPV_inforesp_purge(&I);
|
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));
|
memset(&U,0,sizeof(U));
|
||||||
if ( (slen= NSPV_getaddressutxos(&U,coinaddr)) > 0 )
|
if ( (slen= NSPV_getaddressutxos(&U,coinaddr)) > 0 )
|
||||||
{
|
{
|
||||||
printf("getaddressutxos.(%s) slen.%d\n",coinaddr,slen);
|
|
||||||
response.resize(1 + slen);
|
response.resize(1 + slen);
|
||||||
response[0] = NSPV_UTXOSRESP;
|
response[0] = NSPV_UTXOSRESP;
|
||||||
if ( NSPV_rwutxosresp(1,&response[1],&U) == slen )
|
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 ( 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
|
len = 0;
|
||||||
{
|
msg[len++] = NSPV_INFO;
|
||||||
msg[len++] = NSPV_INFO;
|
NSPV_req(pto,msg,len,NODE_NSPV,NSPV_INFO>>1);
|
||||||
NSPV_req(pto,msg,len,NODE_NSPV,NSPV_INFO>>1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user