Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
456746fdf8
  1. 19
      iguana/iguana_ramchain.c
  2. 10
      iguana/iguana_recv.c

19
iguana/iguana_ramchain.c

@ -439,9 +439,11 @@ uint32_t iguana_ramchain_scriptencode(struct iguana_info *coin,uint8_t *Kspace,u
*pubkeyoffsetp = pubkeyoffset = offset;
memcpy(&Kspace[pubkeyoffset],script+1,plen);
offset += plen;
//for (i=0; i<plen; i++)
// printf("%02x",script[1+i]);
//printf(" pubkey -> pubkeyoffset.%d offset.%d\n",pubkeyoffset,offset);
char buf[1025];
buf[0] = 0;
for (i=0; i<plen; i++)
sprintf(buf+strlen(buf),"%02x",script[1+i]);
printf("%s pubkey -> pubkeyoffset.%d offset.%d plen.%d\n",buf,pubkeyoffset,offset,plen);
}
if ( memcmp(script+1,&Kspace[pubkeyoffset],plen) != 0 )
{
@ -580,17 +582,17 @@ uint32_t iguana_ramchain_addunspent(struct iguana_info *coin,RAMCHAIN_FUNC,uint6
u->prevunspentind = A[pkind].lastunspentind;
//for (i=0; i<20; i++)
// printf("%02x",rmd160[i]);
printf(" U%d scriptoffset.%d pubkeyoffset.%d type.%d pkind.%d\n",unspentind,ramchain->H.scriptoffset,pubkeyoffset,type,pkind);
printf(" U%d scriptoffset.%d pubkeyoffset.%d/%d type.%d pkind.%d\n",unspentind,ramchain->H.scriptoffset,pubkeyoffset,ramchain->H.data->scriptspace,type,pkind);
if ( scriptlen > 0 && script != 0 )
{
//for (i=0; i<scriptlen; i++)
// printf("%02x",script[i]);
//printf(" bp.[%d] u%d\n",hdrsi,unspentind);
if ( Kspace != 0 && ramchain->H.scriptoffset+scriptlen+3 <= ramchain->H.data->scriptspace )
if ( Kspace != 0 && ramchain->H.scriptoffset+scriptlen+3 <= ramchain->H.data->scriptspace-ramchain->H.stacksize )
{
if ( (u->scriptoffset= iguana_ramchain_scriptencode(coin,Kspace,&ramchain->H.scriptoffset,type,script,scriptlen,&pubkeyoffset)) > 0 || type == IGUANA_SCRIPT_76AC )
{
//printf("new offset.%d from scriptlen.%d pubkeyoffset.%d\n",ramchain->H.scriptoffset,scriptlen,pubkeyoffset);
fprintf(stderr,"new offset.%d from scriptlen.%d pubkeyoffset.%d\n",ramchain->H.scriptoffset,scriptlen,pubkeyoffset);
if ( type == IGUANA_SCRIPT_76AC && pubkeyoffset != 0 )
{
P[pkind].pubkeyoffset = pubkeyoffset;
@ -600,7 +602,7 @@ uint32_t iguana_ramchain_addunspent(struct iguana_info *coin,RAMCHAIN_FUNC,uint6
}
}
//printf("[%d] u%d offset.%u len.%d\n",hdrsi,unspentind,u->scriptoffset,scriptlen);
} else printf("[%d] u%d Kspace.%p scriptspace overflow! %d + %d vs space.%d\n",hdrsi,unspentind,Kspace,ramchain->H.scriptoffset,scriptlen,ramchain->H.data->scriptspace);
} else printf("[%d] u%d Kspace.%p scriptspace overflow! %d + %d vs space.%d - stack.%d\n",hdrsi,unspentind,Kspace,ramchain->H.scriptoffset,scriptlen,ramchain->H.data->scriptspace,ramchain->H.stacksize);
}
}
//printf("%p A[%d] last <- U%d\n",&A[pkind],pkind,unspentind);
@ -718,6 +720,7 @@ int32_t iguana_vinscriptdecode(struct iguana_info *coin,int32_t *metalenp,uint32
memcpy(sequenceidp,&metascript[len],sizeof(*sequenceidp));
len += sizeof(*sequenceidp);
} else (*sequenceidp) = -(*sequenceidp);
*metalenp = 0;
len += iguana_rwvarint32(0,&metascript[len],(void *)&totalsize);
if ( totalsize > IGUANA_MAXSCRIPTSIZE )
{
@ -752,6 +755,7 @@ int32_t iguana_vinscriptdecode(struct iguana_info *coin,int32_t *metalenp,uint32
printf("%02x",_script[j]);
printf(" _script\n");
printf(" iguana_vinscriptdecode illegal pubkey.%d\n",i);
return(0);
}
else
{
@ -2445,7 +2449,6 @@ int32_t iguana_bundlesaveHT(struct iguana_info *coin,struct OS_memspace *mem,str
{
if ( (block= bp->blocks[i]) != 0 && block == iguana_blockfind(coin,bp->hashes[i]) )
{
fprintf(stderr,"(%x:%x) ",(uint32_t)block->RO.hash2.ulongs[3],(uint32_t)bp->hashes[i].ulongs[3]);
if ( iguana_blockvalidate(coin,&valid,block,1) != 0 || (bp->bundleheight+i > 0 && bits256_nonz(block->RO.prev_block) == 0) )
{
char str[65]; printf("null prevblock error at ht.%d patch.(%s)\n",bp->bundleheight+i,bits256_str(str,bp->hashes[i-1]));

10
iguana/iguana_recv.c

@ -910,12 +910,16 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr)
struct iguana_block *bestblock = 0; struct iguana_bundle *bestbp = 0; int32_t besti = -1;
n = coin->peers.numranked * 2;
gap = addr->rank * (n + coin->peers.numranked) + coin->peers.numranked;
for (i=0; i<coin->bundlescount; i++)
if ( (bp= coin->bundles[i]) == 0 || bp->emitfinish == 0 )
break;
height = (i * coin->chain->bundlesize);
for (i=0; i<n; i++,gap++)
{
hdrsi = (coin->blocks.hwmchain.height + gap) / coin->chain->bundlesize;
hdrsi = (height + gap) / coin->chain->bundlesize;
if ( (bp= coin->bundles[hdrsi]) != 0 )
{
bundlei = (coin->blocks.hwmchain.height + gap) % coin->chain->bundlesize;
bundlei = (height + gap) % coin->chain->bundlesize;
if ( (block= bp->blocks[bundlei]) != 0 && block->fpipbits == 0 && block->queued == 0 )
{
if ( block->numrequests == 0 )
@ -939,7 +943,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr)
printf("near hwm.%d gap.%d peer.%s bpranked.%d [%d:%d] pending.%d numreqs.%d\n",coin->blocks.hwmchain.height,gap,addr->ipaddr,bestbp->rank,bestbp->hdrsi,besti,addr->pendblocks,bestblock->numrequests);
bestblock->numrequests++;
iguana_sendblockreqPT(coin,addr,bestbp,besti,bestblock->RO.hash2,1);
}
} else printf("addr.%s nothing near to do\n",addr->ipaddr);
}
if ( (bp= addr->bp) != 0 && bp->rank != 0 && addr->pendblocks < limit )
{

Loading…
Cancel
Save