From c1ca2f31f920b87afee58789a2043e869a5ca5ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 10 Mar 2016 22:15:32 -0300 Subject: [PATCH] test --- iguana/iguana777.h | 2 +- iguana/iguana_ramchain.c | 24 +++++++++++++++++++++--- iguana/iguana_recv.c | 8 ++++---- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 2e1d30c42..8b2cdc0dc 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -35,7 +35,7 @@ typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t #define IGUANA_HEADPERCENTAGE .00777 #define IGUANA_TAILPERCENTAGE .777 #define IGUANA_MAXPENDHDRS 1 -#define _IGUANA_MAXPENDING 128 +#define _IGUANA_MAXPENDING 7 #define _IGUANA_MAXBUNDLES 8 #define IGUANA_BUNDLELOOP 13 #define IGUANA_RPCPORT 7778 diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 2380dfaab..c47396f14 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -552,11 +552,16 @@ uint32_t iguana_ramchain_pubkeyoffset(struct iguana_info *coin,RAMCHAIN_FUNC,int int32_t iguana_vinscriptdecode(struct iguana_info *coin,struct iguana_ramchain *ramchain,int32_t *metalenp,uint32_t *sequenceidp,uint8_t _script[IGUANA_MAXSCRIPTSIZE],uint8_t *Kstackend,uint8_t *Kspace,struct iguana_spend *s) { int32_t i,suffixlen,len = 0; long diff; uint8_t *pubkey,*metascript = &Kspace[s->scriptoffset]; uint32_t poffset; int32_t totalsize,sigslen,plen,stacksize=0,p2shlen=0,scriptlen = 0; + if ( s->scriptoffset == 0 ) + { + printf("iguana_vinscriptdecode: null scriptoffset\n"); + return(0); + } if ( (*sequenceidp= s->sequenceid) == 3 ) { len += iguana_rwvarint32(0,&metascript[len],(void *)sequenceidp); - printf("nonstandard sequence decoded.%x\n",*sequenceidp); - } else (*sequenceidp) = -(*sequenceidp); + printf("nonstandard sequence decoded.%x offset.[%d]\n",*sequenceidp,s->scriptoffset); + } else (*sequenceidp) = -(int32_t)(*sequenceidp); *metalenp = 0; len += iguana_rwvarint32(0,&metascript[len],(void *)&totalsize); if ( s->rawmode != 0 ) @@ -564,6 +569,7 @@ int32_t iguana_vinscriptdecode(struct iguana_info *coin,struct iguana_ramchain * *metalenp = 0; if ( totalsize < IGUANA_MAXSCRIPTSIZE ) { + printf("rawmode.%d\n",totalsize); memcpy(_script,&metascript[len],totalsize); return(totalsize); } @@ -584,6 +590,7 @@ int32_t iguana_vinscriptdecode(struct iguana_info *coin,struct iguana_ramchain * len += iguana_rwvarint32(0,&metascript[len],(void *)&stacksize); if ( ramchain->sigsfileptr != 0 && stacksize < ramchain->sigsfilesize ) { + printf("mapped sigslen.%d\n",sigslen); memcpy(&_script[scriptlen],(void *)((long)ramchain->sigsfileptr + ramchain->sigsfilesize - stacksize),sigslen); //printf("mapped emit.%p sigslen.%d [%02x] stacksize.%d\n",(uint8_t *)((long)ramchain->sigsfileptr + ramchain->sigsfilesize - stacksize + sigslen - 1),sigslen,*(uint8_t *)((long)ramchain->sigsfileptr + ramchain->sigsfilesize - stacksize + sigslen - 1),stacksize); } @@ -592,6 +599,7 @@ int32_t iguana_vinscriptdecode(struct iguana_info *coin,struct iguana_ramchain * diff = (long)Kstackend - (long)Kspace; if ( stacksize < diff ) { + printf("sigslen.%d\n",sigslen); memcpy(&_script[scriptlen],&Kspace[diff - stacksize],sigslen); //printf("emit.%p from.%ld sigslen.%d [%02x] stacksize.%d\n",&Kspace[diff - stacksize],diff - stacksize,sigslen,Kspace[diff - stacksize + sigslen - 1],stacksize); } @@ -606,6 +614,11 @@ int32_t iguana_vinscriptdecode(struct iguana_info *coin,struct iguana_ramchain * for (i=0; inumpubkeys; i++) { len += iguana_rwvarint32(0,&metascript[len],(void *)&poffset); + if ( poffset > ramchain->H.data->scriptspace-33 ) + { + printf("illegal poffset.%d/%d\n",poffset,ramchain->H.data->scriptspace); + return(-1); + } //printf("poffset[%d] of %d poffset %x\n",i,s->numpubkeys,poffset); pubkey = &Kspace[poffset]; if ( (plen= bitcoin_pubkeylen(pubkey)) <= 0 ) @@ -624,6 +637,7 @@ int32_t iguana_vinscriptdecode(struct iguana_info *coin,struct iguana_ramchain * else { _script[scriptlen++] = plen; + printf("plen.%d\n",i); memcpy(&_script[scriptlen],pubkey,plen), scriptlen += plen; } } @@ -634,10 +648,14 @@ int32_t iguana_vinscriptdecode(struct iguana_info *coin,struct iguana_ramchain * if ( p2shlen <= 75 ) _script[scriptlen++] = 0x4c, _script[scriptlen++] = p2shlen; else _script[scriptlen++] = 0x4d, _script[scriptlen++] = p2shlen & 0xff, _script[scriptlen++] = (p2shlen>>8) & 0xff; + printf("p2shlen.%d\n",p2shlen); memcpy(&_script[scriptlen],&metascript[len],p2shlen), scriptlen += p2shlen, len += p2shlen; } if ( (suffixlen= (totalsize - len)) != 0 ) + { + printf("suffixlen.%d\n",suffixlen); memcpy(&_script[scriptlen],&metascript[len],suffixlen), scriptlen += suffixlen, len += suffixlen; + } //printf("vindecode[%d] -> stacksize.%d sigslen.%d numsigs.%d numpubs.%d p2shlen.%d suffixlen.%d = %d totalsize.%d len.%d\n",s->scriptoffset,stacksize,sigslen,s->numsigs,s->numpubkeys,p2shlen,suffixlen,scriptlen,totalsize,len); *metalenp = len; return(scriptlen); @@ -772,7 +790,7 @@ int32_t iguana_metascript(struct iguana_info *coin,RAMCHAIN_FUNC,struct iguana_s if ( s->sequenceid == 3 ) { ramchain->H.scriptoffset += iguana_rwvarint32(1,&Kspace[s->scriptoffset],(void *)&sequence); - printf("nonstandard sequence encoded.%x\n",sequence); + printf("nonstandard sequence encoded.%x -> [%d]\n",sequence,s->scriptoffset); } ramchain->H.scriptoffset += iguana_rwvarint32(1,&Kspace[s->scriptoffset],(void *)&vinscriptlen); memcpy(&Kspace[ramchain->H.scriptoffset],vinscript,vinscriptlen); diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 40b86e4f7..ce404e0a9 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1038,13 +1038,13 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) int32_t iguana_reqblocks(struct iguana_info *coin) { int32_t hdrsi,lflag,n,bundlei,flag = 0; bits256 hash2; struct iguana_block *next,*block; struct iguana_bundle *bp; - if ( 0 && (bp= coin->current) != 0 && bp->numsaved < bp->n ) // queue_size(&coin->priorityQ) == 0 && + if ( (bp= coin->current) != 0 && bp->numsaved < bp->n ) // queue_size(&coin->priorityQ) == 0 && { - for (hdrsi=0; hdrsipeers.numranked&&coin->current->hdrsi+hdrsibundlescount; hdrsi++) + for (hdrsi=0; hdrsi<3*coin->peers.numranked&&coin->current->hdrsi+hdrsibundlescount; hdrsi++) { - if ( (bp= coin->bundles[hdrsi + coin->current->hdrsi]) == 0 ) + if ( (bp= coin->bundles[hdrsi/3 + coin->current->hdrsi]) == 0 ) continue; - if ( coin->peers.ranked[hdrsi] == 0 || coin->peers.ranked[hdrsi]->msgcounts.verack == 0 ) + if ( coin->peers.ranked[hdrsi/3] == 0 || coin->peers.ranked[hdrsi/3]->msgcounts.verack == 0 ) continue; for (bundlei=n=flag=0; bundlein; bundlei++) if ( (block= bp->blocks[bundlei]) != 0 )