Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
c9e363a2a4
  1. 21
      iguana/iguana_bundles.c

21
iguana/iguana_bundles.c

@ -374,7 +374,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int
now = (uint32_t)time(NULL); now = (uint32_t)time(NULL);
memset(peercounts,0,sizeof(peercounts)); memset(peercounts,0,sizeof(peercounts));
memset(donecounts,0,sizeof(donecounts)); memset(donecounts,0,sizeof(donecounts));
if ( bp == coin->current ) //if ( bp == coin->current )
{ {
if ( bp->numhashes >= bp->n && (numpeers= coin->peers.numranked) > 8 ) if ( bp->numhashes >= bp->n && (numpeers= coin->peers.numranked) > 8 )
{ {
@ -421,6 +421,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int
if ( (len= iguana_getdata(coin,serialized,MSG_BLOCK,hashes,k)) > 0 ) if ( (len= iguana_getdata(coin,serialized,MSG_BLOCK,hashes,k)) > 0 )
{ {
iguana_send(coin,addr,serialized,len); iguana_send(coin,addr,serialized,len);
counter += k;
coin->numreqsent += k; coin->numreqsent += k;
addr->pendblocks += k; addr->pendblocks += k;
addr->pendtime = (uint32_t)time(NULL); addr->pendtime = (uint32_t)time(NULL);
@ -430,7 +431,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int
} }
} }
} }
printf("minval.%d maxval.%d\n",minval,maxval); //printf("minval.%d maxval.%d\n",minval,maxval);
if ( minval != maxval ) if ( minval != maxval )
{ {
r = rand() % numpeers; r = rand() % numpeers;
@ -454,19 +455,29 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int
for (i=0; i<numpeers; i++) for (i=0; i<numpeers; i++)
{ {
j = (i + r) % numpeers; j = (i + r) % numpeers;
if ( donecounts[j] == minval && (addr= coin->peers.ranked[j]) != 0 ) if ( (addr= coin->peers.ranked[j]) != 0 )
{ {
printf("send to addr[%d]\n",j); printf("send to addr[%d]\n",j);
oldest->issued = (uint32_t)time(NULL); oldest->issued = (uint32_t)time(NULL);
oldest->peerid = j + 1; oldest->peerid = j + 1;
counter++;
iguana_sendblockreqPT(coin,addr,bp,oldest->bundlei,oldest->RO.hash2,0); iguana_sendblockreqPT(coin,addr,bp,oldest->bundlei,oldest->RO.hash2,0);
break; break;
} }
} }
} }
} }
for (i=0; i<numpeers; i++) if ( bp->numsaved < bp->n*.95 )
printf("%d ",peercounts[i]); {
for (i=0; i<numpeers; i++)
printf("%d ",peercounts[i]);
}
else
{
for (i=0; i<bp->n; i++)
if ( (block= bp->blocks[i]) != 0 && block->fpipbits == 0 )
printf("%d ",i);
}
printf("currentflag.%d\n",bp->currentflag); printf("currentflag.%d\n",bp->currentflag);
return(counter); return(counter);
} }

Loading…
Cancel
Save