From 9e33b26ecaff33e099ec5e81633740bfcc1e5df3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 31 Oct 2016 13:58:22 -0300 Subject: [PATCH] test --- basilisk/basilisk.c | 4 +-- basilisk/basilisk_MSG.c | 4 +-- basilisk/basilisk_ping.c | 2 +- crypto777/OS_portable.h | 10 ++++--- crypto777/iguana_OS.c | 53 +++++++++++++++++++++----------- crypto777/iguana_utils.c | 4 +-- iguana/iguana777.c | 6 ++-- iguana/iguana_accept.c | 10 +++---- iguana/iguana_bundles.c | 16 +++++----- iguana/iguana_exchanges.c | 20 ++++++------- iguana/iguana_init.c | 25 ++++++++-------- iguana/iguana_peers.c | 18 +++++------ iguana/iguana_recv.c | 58 +++++++++++++++++++----------------- iguana/iguana_spendvectors.c | 2 +- iguana/main.c | 12 ++++---- iguana/pangea_hand.c | 10 +++---- 16 files changed, 138 insertions(+), 116 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 39c49c775..37a98c1ac 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -773,7 +773,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende int32_t basilisk_p2pQ_process(struct supernet_info *myinfo,int32_t maxiters) { struct basilisk_p2pitem *ptr; char senderip[64]; uint32_t n=0,basilisktag,len; - while ( n < maxiters && (ptr= queue_dequeue(&myinfo->p2pQ,0)) != 0 ) + while ( n < maxiters && (ptr= queue_dequeue(&myinfo->p2pQ)) != 0 ) { len = 0; expand_ipbits(senderip,ptr->ipbits); @@ -835,7 +835,7 @@ void basilisk_p2p(struct supernet_info *myinfo,struct iguana_info *coin,struct i ipbits = (uint32_t)calc_ipbits(senderip); else ipbits = myinfo->myaddr.myipbits; ptr = basilisk_p2pitem_create(coin,addr,type,ipbits,data,datalen); - queue_enqueue("p2pQ",&myinfo->p2pQ,ptr,0); + queue_enqueue("p2pQ",&myinfo->p2pQ,ptr); } int32_t basilisk_issued_purge(struct supernet_info *myinfo,int32_t timepad) diff --git a/basilisk/basilisk_MSG.c b/basilisk/basilisk_MSG.c index 332aaaaf8..ba6fd9739 100755 --- a/basilisk/basilisk_MSG.c +++ b/basilisk/basilisk_MSG.c @@ -198,7 +198,7 @@ char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int3 //printf("overwrite update of msg.[%d] <- datalen.%d\n",msg->datalen,datalen); memcpy(msg->data,data,datalen); if ( sendping != 0 ) - queue_enqueue("basilisk_message",&myinfo->msgQ,&msg->DL,0); + queue_enqueue("basilisk_message",&myinfo->msgQ,&msg->DL); } portable_mutex_unlock(&myinfo->messagemutex); return(clonestr("{\"result\":\"message updated\"}")); @@ -223,7 +223,7 @@ char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int3 //if ( myinfo->NOTARY.RELAYID >= 0 ) // dpow_handler(myinfo,msg); if ( sendping != 0 ) - queue_enqueue("basilisk_message",&myinfo->msgQ,&msg->DL,0); + queue_enqueue("basilisk_message",&myinfo->msgQ,&msg->DL); return(clonestr("{\"result\":\"message added to hashtable\"}")); } diff --git a/basilisk/basilisk_ping.c b/basilisk/basilisk_ping.c index 53d5aa2d4..c02e805f2 100755 --- a/basilisk/basilisk_ping.c +++ b/basilisk/basilisk_ping.c @@ -143,7 +143,7 @@ int32_t basilisk_ping_processMSG(struct supernet_info *myinfo,uint32_t senderipb int32_t basilisk_ping_genMSG(struct supernet_info *myinfo,uint8_t *data,int32_t maxlen) { struct basilisk_message *msg; int32_t datalen = 0; - if ( maxlen > sizeof(msg->key) && (msg= queue_dequeue(&myinfo->msgQ,0)) != 0 ) // oneshot ping + if ( maxlen > sizeof(msg->key) && (msg= queue_dequeue(&myinfo->msgQ)) != 0 ) // oneshot ping { data[datalen++] = 1; data[datalen++] = msg->keylen; diff --git a/crypto777/OS_portable.h b/crypto777/OS_portable.h index 1b8603042..f0d61365e 100755 --- a/crypto777/OS_portable.h +++ b/crypto777/OS_portable.h @@ -133,6 +133,8 @@ int32_t hseek(HUFF *hp,int32_t offset,int32_t mode); struct allocitem { uint32_t allocsize,type; } PACKED; struct queueitem { struct queueitem *next,*prev; uint32_t allocsize,type; } PACKED; +struct stritem { struct queueitem DL; char str[]; }; + typedef struct queue { struct queueitem *list; @@ -249,14 +251,14 @@ void OS_randombytes(uint8_t *x,long xlen); long myallocated(uint8_t type,long change); void *mycalloc(uint8_t type,int32_t n,long itemsize); void myfree(void *_ptr,long allocsize); -void free_queueitem(void *itemdata); +//void free_queueitem(void *itemdata); void *myrealloc(uint8_t type,void *oldptr,long oldsize,long newsize); void *myaligned_alloc(uint64_t allocsize); int32_t myaligned_free(void *ptr,long size); -void *queueitem(char *str); -void queue_enqueue(char *name,queue_t *queue,struct queueitem *origitem,int32_t offsetflag); -void *queue_dequeue(queue_t *queue,int32_t offsetflag); +struct queueitem *queueitem(char *str); +void queue_enqueue(char *name,queue_t *queue,struct queueitem *origitem);//,int32_t offsetflag); +void *queue_dequeue(queue_t *queue);//,int32_t offsetflag); void *queue_delete(queue_t *queue,struct queueitem *copy,int32_t copysize,int32_t freeitem); void *queue_free(queue_t *queue); void *queue_clone(queue_t *clone,queue_t *queue,int32_t size); diff --git a/crypto777/iguana_OS.c b/crypto777/iguana_OS.c index a430535ab..9d03ea851 100755 --- a/crypto777/iguana_OS.c +++ b/crypto777/iguana_OS.c @@ -94,6 +94,7 @@ long myallocated(uint8_t type,long change) void *mycalloc(uint8_t type,int32_t n,long itemsize) { +#ifdef USE_MYCALLOC //static portable_mutex_t MEMmutex; struct allocitem *item; int64_t allocsize = ((uint64_t)n * itemsize); if ( type == 0 && n == 0 && itemsize == 0 ) @@ -115,11 +116,14 @@ void *mycalloc(uint8_t type,int32_t n,long itemsize) item->type = type; //portable_mutex_unlock(&MEMmutex); return((void *)((long)item + sizeof(*item))); +#else + return(calloc(n,itemsize)); +#endif } -void *queueitem(char *str) +struct queueitem *queueitem(char *str) { - struct queueitem *item; int32_t n,allocsize; char *data; uint8_t type = 'y'; + /*struct queueitem *item; int32_t n,allocsize; char *data; uint8_t type = 'y'; //portable_mutex_lock(&MEMmutex); n = (uint32_t)strlen(str) + 1; allocsize = (uint32_t)(sizeof(struct queueitem) + n); @@ -136,9 +140,15 @@ void *queueitem(char *str) memcpy(data,str,n); //printf("(%c) queueitem.%p itemdata.%p n.%d allocsize.%d\n",type,item,data,n,allocsize); //portable_mutex_unlock(&MEMmutex); - return(data); + return(data);*/ + struct stritem *sitem; int32_t len; + len = (int32_t)strlen(str); + sitem = calloc(1,sizeof(*sitem) + len + 1); + memcpy(sitem->str,str,len); + return(&sitem->DL); } +#ifdef USE_MYCALLOC void _myfree(uint8_t type,int32_t origallocsize,void *origptr,int32_t allocsize) { //portable_mutex_lock(&MEMmutex); @@ -171,12 +181,12 @@ void myfree(void *_ptr,long allocsize) _myfree(item->type,item->allocsize,item,(uint32_t)allocsize); } -void free_queueitem(void *itemdata) +/*void free_queueitem(void *itemdata) { struct queueitem *item = (void *)((long)itemdata - sizeof(struct queueitem)); //printf("freeq item.%p itemdata.%p size.%d\n",item,itemdata,item->allocsize); _myfree(item->type,item->allocsize,item,item->allocsize); -} +}*/ void *myrealloc(uint8_t type,void *oldptr,long oldsize,long newsize) { @@ -190,6 +200,17 @@ void *myrealloc(uint8_t type,void *oldptr,long oldsize,long newsize) } return(newptr); } +#else +void myfree(void *_ptr,long allocsize) +{ + free(_ptr); +} + +void *myrealloc(uint8_t type,void *oldptr,long oldsize,long newsize) +{ + return(realloc(oldptr,newsize)); +} +#endif static uint64_t _align16(uint64_t ptrval) { if ( (ptrval & 15) != 0 ) ptrval += 16 - (ptrval & 15); return(ptrval); } @@ -235,25 +256,20 @@ void lock_queue(queue_t *queue) portable_mutex_lock(&queue->mutex); } -void queue_enqueue(char *name,queue_t *queue,struct queueitem *origitem,int32_t offsetflag) +void queue_enqueue(char *name,queue_t *queue,struct queueitem *item)//,int32_t offsetflag) { - struct queueitem *item; + //struct queueitem *item; if ( queue->name[0] == 0 && name != 0 && name[0] != 0 ) strcpy(queue->name,name);//,sizeof(queue->name)); - if ( origitem == 0 ) - { - printf("FATAL type error: queueing empty value\n");//, getchar(); - return; - } //fprintf(stderr,"enqueue.(%s) %p offset.%d\n",queue->name,origitem,offsetflag); lock_queue(queue); - item = (struct queueitem *)((long)origitem - offsetflag*sizeof(struct queueitem)); + //item = (struct queueitem *)((long)origitem - offsetflag*sizeof(struct queueitem)); DL_APPEND(queue->list,item); portable_mutex_unlock(&queue->mutex); //printf("queue_enqueue name.(%s) origitem.%p append.%p list.%p\n",name,origitem,item,queue->list); } -void *queue_dequeue(queue_t *queue,int32_t offsetflag) +void *queue_dequeue(queue_t *queue)//,int32_t offsetflag) { struct queueitem *item = 0; lock_queue(queue); @@ -264,9 +280,10 @@ void *queue_dequeue(queue_t *queue,int32_t offsetflag) DL_DELETE(queue->list,item); } portable_mutex_unlock(&queue->mutex); - if ( item != 0 && offsetflag != 0 ) - return((void *)((long)item + sizeof(struct queueitem))); - else return(item); + //if ( item != 0 && offsetflag != 0 ) + // return((void *)((long)item + sizeof(struct queueitem))); + //else + return(item); } void *queue_delete(queue_t *queue,struct queueitem *copy,int32_t copysize,int32_t freeitem) @@ -321,7 +338,7 @@ void *queue_clone(queue_t *clone,queue_t *queue,int32_t size) { ptr = mycalloc('c',1,sizeof(*ptr)); memcpy(ptr,item,size); - queue_enqueue(queue->name,clone,ptr,0); + queue_enqueue(queue->name,clone,ptr); } //printf("name.(%s) dequeue.%p list.%p\n",queue->name,item,queue->list); } diff --git a/crypto777/iguana_utils.c b/crypto777/iguana_utils.c index 870dc4bf5..6b11b668b 100755 --- a/crypto777/iguana_utils.c +++ b/crypto777/iguana_utils.c @@ -268,7 +268,7 @@ void iguana_launcher(void *ptr) t->funcp(t->arg); if ( coin != 0 ) coin->Terminated[t->type % (sizeof(coin->Terminated)/sizeof(*coin->Terminated))]++; - queue_enqueue("TerminateQ",&TerminateQ,&t->DL,0); + queue_enqueue("TerminateQ",&TerminateQ,&t->DL); } void iguana_terminate(struct iguana_thread *t) @@ -296,7 +296,7 @@ struct iguana_thread *iguana_launch(struct iguana_info *coin,char *name,iguana_f retval = OS_thread_create(&t->handle,NULL,(void *)iguana_launcher,(void *)t); if ( retval != 0 ) printf("error launching %s\n",t->name); - while ( (t= queue_dequeue(&TerminateQ,0)) != 0 ) + while ( (t= queue_dequeue(&TerminateQ)) != 0 ) { if ( (rand() % 100000) == 0 && coin != 0 ) printf("terminated.%d launched.%d terminate.%p\n",coin->Terminated[t->type],coin->Launched[t->type],t); diff --git a/iguana/iguana777.c b/iguana/iguana777.c index e1d886a3f..ea62d9740 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -266,7 +266,7 @@ void iguana_emitQ(struct iguana_info *coin,struct iguana_bundle *bp) ptr->type = 'E'; ptr->starttime = (uint32_t)time(NULL); //printf("%s EMIT.%d[%d] emitfinish.%u\n",coin->symbol,ptr->hdrsi,bp->n,bp->emitfinish); - queue_enqueue("emitQ",&emitQ,&ptr->DL,0); + queue_enqueue("emitQ",&emitQ,&ptr->DL); } void iguana_bundleQ(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit) @@ -293,7 +293,7 @@ void iguana_bundleQ(struct supernet_info *myinfo,struct iguana_info *coin,struct ptr->timelimit = timelimit; coin->numbundlesQ++; // printf("%s.%d %p bundle.%d[%d] ht.%d emitfinish.%u\n",coin->symbol,n,bp,ptr->hdrsi,bp->n,bp->bundleheight,bp->emitfinish); - queue_enqueue("bundlesQ",&bundlesQ,&ptr->DL,0); + queue_enqueue("bundlesQ",&bundlesQ,&ptr->DL); } else { @@ -766,7 +766,7 @@ void iguana_helper(void *arg) n = queue_size(&bundlesQ); for (iter=0; itercoin; diff --git a/iguana/iguana_accept.c b/iguana/iguana_accept.c index b4e18435b..835e68828 100755 --- a/iguana/iguana_accept.c +++ b/iguana/iguana_accept.c @@ -134,7 +134,7 @@ void iguana_acceptloop(void *args) ptr->sock = sock; ptr->port = cli_addr.sin_port; printf("queue PENDING ACCEPTS\n"); - queue_enqueue("acceptQ",&coin->acceptQ,&ptr->DL,0); + queue_enqueue("acceptQ",&coin->acceptQ,&ptr->DL); } else { @@ -152,7 +152,7 @@ void iguana_acceptloop(void *args) int32_t iguana_pendingaccept(struct iguana_info *coin) { struct iguana_accept *ptr; char ipaddr[64]; struct iguana_peer *addr; - if ( (ptr= queue_dequeue(&coin->acceptQ,0)) != 0 ) + if ( (ptr= queue_dequeue(&coin->acceptQ)) != 0 ) { if ( (addr= iguana_peerslot(coin,ptr->ipbits,0)) != 0 ) { @@ -163,7 +163,7 @@ int32_t iguana_pendingaccept(struct iguana_info *coin) iguana_launch(coin,"accept",iguana_dedicatedglue,addr,IGUANA_CONNTHREAD); myfree(ptr,sizeof(*ptr)); return(1); - } else queue_enqueue("requeue_acceptQ",&coin->acceptQ,&ptr->DL,0); + } else queue_enqueue("requeue_acceptQ",&coin->acceptQ,&ptr->DL); } return(0); } @@ -185,13 +185,13 @@ void iguana_msgrequestQ(struct iguana_info *coin,struct iguana_peer *addr,int32_ msg->addr = addr; msg->hash2 = hash2; msg->type = type; - queue_enqueue("msgrequest",&coin->msgrequestQ,&msg->DL,0); + queue_enqueue("msgrequest",&coin->msgrequestQ,&msg->DL); } int32_t iguana_process_msgrequestQ(struct supernet_info *myinfo,struct iguana_info *coin) { struct iguana_peermsgrequest *msg; int32_t height,len,flag = 0; bits256 checktxid; struct iguana_txid *tx,T; struct iguana_peer *addr; - if ( (msg= queue_dequeue(&coin->msgrequestQ,0)) != 0 ) + if ( (msg= queue_dequeue(&coin->msgrequestQ)) != 0 ) { flag = 1; if ( msg->addr != 0 ) diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 1dd027813..be66da25f 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -685,7 +685,7 @@ int32_t iguana_bundleissuemissing(struct supernet_info *myinfo,struct iguana_inf req->bp = bp; req->height = bp->bundleheight + i; req->bundlei = i; - queue_enqueue("missing",&coin->priorityQ,&req->DL,0); + queue_enqueue("missing",&coin->priorityQ,&req->DL); bp->issued[i] = 1; n++; if ( 0 && bp == coin->current ) @@ -749,7 +749,7 @@ int32_t iguana_blast(struct iguana_info *coin,struct iguana_peer *addr) req->bp = bp; req->height = bp->bundleheight + i; req->bundlei = i; - queue_enqueue("blast",&coin->priorityQ,&req->DL,0); + queue_enqueue("blast",&coin->priorityQ,&req->DL); } } if ( n > m ) @@ -881,7 +881,7 @@ int32_t iguana_bundlehdr(struct supernet_info *myinfo,struct iguana_info *coin,s if ( time(NULL) > bp->hdrtime+dist && (bp == coin->current || bp->hdrsi >= coin->bundlescount-2 || (strcmp("BTC",coin->symbol) != 0 && bp->numhashes < bp->n && (bp->speculative == 0 || bp->hdrsi >= coin->longestchain/bp->n))) ) { bp->hdrtime = (uint32_t)time(NULL); - queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1); + queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0]))); } if ( time(NULL) > bp->hdrtime+dist && strcmp("BTC",coin->symbol) != 0 && (bp == coin->current || bp->hdrsi == coin->bundlescount-1) && bits256_nonz(bp->nextbundlehash2) == 0 ) { @@ -892,7 +892,7 @@ int32_t iguana_bundlehdr(struct supernet_info *myinfo,struct iguana_info *coin,s if ( GETBIT(bp->haveblock,i) == 0 ) bp->issued[i] = 0; bp->hdrtime = (uint32_t)time(NULL); - queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1); + queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0]))); } iguana_bundleissuemissing(myinfo,coin,bp,3,3.); /*if ( bp == coin->current ) @@ -1041,7 +1041,7 @@ int32_t iguana_bundlefinalize(struct supernet_info *myinfo,struct iguana_info *c printf(">>>>>>>>>>>>>> EMIT.[%3d] %s | 1st.%-3d h.%-3d c.%-3d s.[%3d] maxB.%d NET.(h%d b%d) %u:%02u\n",bp->hdrsi,coin->symbol,coin->current!=0?coin->current->hdrsi:-1,coin->current!=0?coin->current->numhashes:-1,coin->current!=0?coin->current->numcached:-1,coin->current!=0?coin->current->numsaved:-1,coin->MAXBUNDLES,HDRnet,queue_size(&coin->priorityQ),(uint32_t)(time(NULL)-coin->startutc)/60,(uint32_t)(time(NULL)-coin->startutc)%60); if ( queue_size(&coin->priorityQ) > 10000 ) { - while ( (breq= queue_dequeue(&coin->priorityQ,0)) != 0 ) + while ( (breq= queue_dequeue(&coin->priorityQ)) != 0 ) myfree(breq,sizeof(*breq)); //printf("cleared priorityQ\n"); } @@ -1486,9 +1486,9 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch coin->stuckiters = (int32_t)(lag/coin->MAXSTUCKTIME); if ( coin->stuckiters > 2 ) { - while ( (breq= queue_dequeue(&coin->blocksQ,0)) != 0 ) + while ( (breq= queue_dequeue(&coin->blocksQ)) != 0 ) myfree(breq,sizeof(*breq)); - while ( (breq= queue_dequeue(&coin->priorityQ,0)) != 0 ) + while ( (breq= queue_dequeue(&coin->priorityQ)) != 0 ) myfree(breq,sizeof(*breq)); for (i=0; in; i++) { @@ -1562,7 +1562,7 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch coin->estsize = estsize; if ( queue_size(&coin->priorityQ) > 10000 ) { - while ( (breq= queue_dequeue(&coin->priorityQ,0)) != 0 ) + while ( (breq= queue_dequeue(&coin->priorityQ)) != 0 ) myfree(breq,sizeof(*breq)); //printf("cleared priorityQ\n"); } diff --git a/iguana/iguana_exchanges.c b/iguana/iguana_exchanges.c index bf897c94f..1b8b6c859 100755 --- a/iguana/iguana_exchanges.c +++ b/iguana/iguana_exchanges.c @@ -754,7 +754,7 @@ void exchanges777_loop(void *ptr) PAX_idle(myinfo); flag = retval = 0; retstr = 0; - if ( (req= queue_dequeue(&exchange->requestQ,0)) != 0 ) + if ( (req= queue_dequeue(&exchange->requestQ)) != 0 ) { //printf("dequeued %s.%c\n",exchange->name,req->func); if ( req->dead == 0 ) @@ -782,7 +782,7 @@ void exchanges777_loop(void *ptr) // queue_enqueue("Xpending",&exchange->pendingQ,&req->DL,0), flag++; //else if ( retval == EXCHANGE777_REQUEUE ) - queue_enqueue("requeue",&exchange->requestQ,&req->DL,0); + queue_enqueue("requeue",&exchange->requestQ,&req->DL); else { printf("exchanges777_process: illegal retval.%d\n",retval); @@ -805,7 +805,7 @@ void exchanges777_loop(void *ptr) iguana_statemachineupdate(myinfo,exchange); //printf("InstantDEX call update\n"); }*/ - if ( (req= queue_dequeue(&exchange->pricesQ,0)) != 0 ) + if ( (req= queue_dequeue(&exchange->pricesQ)) != 0 ) { //printf("check %s pricesQ (%s %s)\n",exchange->name,req->base,req->rel); if ( req->dead == 0 ) @@ -824,7 +824,7 @@ void exchanges777_loop(void *ptr) //printf("%-10s %s/%s numbids.%d numasks.%d\n",exchange->name,req->base,req->rel,req->numbids,req->numasks); prices777_processprice(exchange,req->base,req->rel,req->bidasks,req->depth); } - queue_enqueue("pricesQ",&exchange->pricesQ,&req->DL,0); + queue_enqueue("pricesQ",&exchange->pricesQ,&req->DL); } else { @@ -843,12 +843,12 @@ struct exchange_request *exchanges777_baserelfind(struct exchange_info *exchange { struct exchange_request PAD,*req,*retreq=0; memset(&PAD,0,sizeof(PAD)); - queue_enqueue("pricesQ",&exchange->pricesQ,&PAD.DL,0); - while ( (req= queue_dequeue(&exchange->pricesQ,0)) != 0 && req != &PAD ) + queue_enqueue("pricesQ",&exchange->pricesQ,&PAD.DL); + while ( (req= queue_dequeue(&exchange->pricesQ)) != 0 && req != &PAD ) { if ( ((req->invert == 0 && strcmp(base,req->base) == 0 && strcmp(rel,req->rel) == 0) || (req->invert != 0 && strcmp(rel,req->base) == 0 && strcmp(base,req->rel) == 0)) && (func < 0 || req->func == func) ) retreq = req; - queue_enqueue("pricesQ",&exchange->pricesQ,&req->DL,0); + queue_enqueue("pricesQ",&exchange->pricesQ,&req->DL); } return(retreq); } @@ -875,7 +875,7 @@ char *exchanges777_submit(struct exchange_info *exchange,struct exchange_request maxseconds = EXCHANGES777_DEFAULT_TIMEOUT; retstrp = req->retstrp; //printf("submit to %p\n",&exchange->requestQ); - queue_enqueue("exchangeQ",&exchange->requestQ,&req->DL,0); + queue_enqueue("exchangeQ",&exchange->requestQ,&req->DL); for (i=0; ifunc = 'M'; //printf("Monitor.%s (%s %s) invert.%d\n",exchange->name,base,rel,req->invert); - queue_enqueue("pricesQ",&exchange->pricesQ,&req->DL,0); + queue_enqueue("pricesQ",&exchange->pricesQ,&req->DL); return(clonestr("{\"result\":\"start monitoring\"}")); } } @@ -1009,7 +1009,7 @@ void iguana_gotquotesM(struct iguana_info *coin,struct iguana_peer *addr,bits256 //printf("got %d quotes from %s\n",n,addr->ipaddr); req = iguana_bundlereq(coin,addr,'Q',0,0); req->hashes = quotes, req->n = n; - queue_enqueue("recvQ",&exchange->recvQ,&req->DL,0); + queue_enqueue("recvQ",&exchange->recvQ,&req->DL); } struct exchange_info *exchange_create(char *exchangestr,cJSON *argjson) diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 2c7abc699..47fc657d2 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -17,12 +17,13 @@ void iguana_initQ(queue_t *Q,char *name) { - char *tst,*str = "need to init each Q when single threaded"; + struct queueitem *item,*ptr; + item = calloc(1,sizeof(*item)); memset(Q,0,sizeof(*Q)); strcpy(Q->name,name); - queue_enqueue(name,Q,queueitem(str),1); - if ( (tst= queue_dequeue(Q,1)) != 0 ) - free_queueitem(tst); + queue_enqueue(name,Q,item); + if ( (ptr= queue_dequeue(Q)) != 0 ) + free(ptr); } void iguana_initQs(struct iguana_info *coin) @@ -470,7 +471,7 @@ void iguana_blockspurge(struct iguana_info *coin) void iguana_coinpurge(struct iguana_info *coin) { - int32_t i,saved; struct iguana_bundle *bp; char *hashstr; struct iguana_bundlereq *req; struct iguana_blockreq *breq; struct iguana_helper *ptr; + int32_t i,saved; struct iguana_bundle *bp; struct iguana_bundlereq *req; struct iguana_blockreq *breq; struct iguana_helper *ptr; struct stritem *hashitem; saved = coin->active, coin->active = 0; coin->started = 0; while ( coin->idletime == 0 && coin->emitbusy > 0 ) @@ -479,19 +480,19 @@ void iguana_coinpurge(struct iguana_info *coin) sleep(1); } coin->RTgenesis = 0; - while ( (ptr= queue_dequeue(&bundlesQ,0)) != 0 ) + while ( (ptr= queue_dequeue(&bundlesQ)) != 0 ) myfree(ptr,ptr->allocsize); if ( 1 ) { - while ( (hashstr= queue_dequeue(&coin->hdrsQ,1)) != 0 ) - free_queueitem(hashstr); - while ( (breq= queue_dequeue(&coin->blocksQ,0)) != 0 ) + while ( (hashitem= queue_dequeue(&coin->hdrsQ)) != 0 ) + free(hashitem); + while ( (breq= queue_dequeue(&coin->blocksQ)) != 0 ) myfree(breq,sizeof(*breq)); - while ( (breq= queue_dequeue(&coin->priorityQ,0)) != 0 ) + while ( (breq= queue_dequeue(&coin->priorityQ)) != 0 ) myfree(breq,sizeof(*breq)); - while ( (req= queue_dequeue(&coin->cacheQ,0)) != 0 ) + while ( (req= queue_dequeue(&coin->cacheQ)) != 0 ) myfree(req,req->allocsize); - while ( (req= queue_dequeue(&coin->recvQ,0)) != 0 ) + while ( (req= queue_dequeue(&coin->recvQ)) != 0 ) { if ( req->blocks != 0 ) myfree(req->blocks,sizeof(*req->blocks) * req->n), req->blocks = 0; diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index a1bcead84..a790c69ab 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -562,7 +562,7 @@ int32_t iguana_queue_send(struct iguana_peer *addr,int32_t delay,uint8_t *serial memcpy(packet->serialized,serialized,datalen); if ( 0 && addr->supernet != 0 ) printf("%p queue send.(%s) %d to (%s)\n",packet,serialized+4,datalen,addr->ipaddr); - queue_enqueue("sendQ",&addr->sendQ,&packet->DL,0); + queue_enqueue("sendQ",&addr->sendQ,&packet->DL); return(datalen); } @@ -895,7 +895,7 @@ void *iguana_iAddriterator(struct iguana_info *coin,struct iguana_iAddr *iA,stru uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr) { - char checkaddr[64],_ipaddr[64]; uint64_t ipbits; uint32_t now = (uint32_t)time(NULL); int32_t i,n; struct iguana_iAddr *iA; struct iguana_peer *addr; + char checkaddr[64],_ipaddr[64]; uint64_t ipbits; uint32_t now = (uint32_t)time(NULL); int32_t i,n; struct iguana_iAddr *iA; struct iguana_peer *addr; struct stritem *sitem; if ( coin->virtualchain != 0 || coin->peers == 0 ) return(0); if ( ipaddr != 0 && ipaddr[0] != 0 && coin->peers != 0 ) @@ -909,15 +909,15 @@ uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr) return(0); } //printf("%s Q possible.(%s)\n",coin->symbol,ipaddr); - queue_enqueue("possibleQ",&coin->possibleQ,queueitem(ipaddr),1); + queue_enqueue("possibleQ",&coin->possibleQ,queueitem(ipaddr)); return((uint32_t)time(NULL)); } else if ( iguana_pendingaccept(coin) != 0 ) return((uint32_t)time(NULL)); - else if ( (ipaddr= queue_dequeue(&coin->possibleQ,1)) == 0 ) + else if ( (sitem= queue_dequeue(&coin->possibleQ)) == 0 ) return((uint32_t)time(NULL)); - safecopy(_ipaddr,ipaddr,sizeof(_ipaddr)); - free_queueitem(ipaddr); + safecopy(_ipaddr,sitem->str,sizeof(_ipaddr)); + free(sitem); ipaddr = _ipaddr; #ifdef IGUANA_DISABLEPEERS if ( strcmp(ipaddr,"127.0.0.1") != 0 ) @@ -985,7 +985,7 @@ void iguana_processmsg(void *ptr) int32_t iguana_pollsendQ(struct iguana_info *coin,struct iguana_peer *addr) { struct iguana_packet *packet; - if ( (packet= queue_dequeue(&addr->sendQ,0)) != 0 ) + if ( (packet= queue_dequeue(&addr->sendQ)) != 0 ) { if ( 0 && (addr->supernet != 0 || strcmp((char *)&packet->serialized[4],"SuperNET") == 0) ) printf("%s: send.(%s).%d usock.%d dead.%u ready.%u supernet.%d\n",addr->ipaddr,packet->serialized+4,packet->datalen,addr->usock,addr->dead,addr->ready,addr->supernet); @@ -1003,7 +1003,7 @@ int32_t iguana_pollsendQ(struct iguana_info *coin,struct iguana_peer *addr) else { //printf("embargo.x %llu %f\n",(long long)packet->embargo.x,tai_diff(packet->embargo,tai_now())); - queue_enqueue("embargo",&addr->sendQ,&packet->DL,0); + queue_enqueue("embargo",&addr->sendQ,&packet->DL); } } return(0); @@ -1226,7 +1226,7 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin, run = 0; while ( addr->usock >= 0 && addr->dead == 0 && coin->peers->shuttingdown == 0 ) { - if ( (req= queue_dequeue(&coin->cacheQ,0)) != 0 ) + if ( (req= queue_dequeue(&coin->cacheQ)) != 0 ) { if ( req->datalen != 0 ) { diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 9126f6708..827ba0493 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -185,7 +185,7 @@ void iguana_gotunconfirmedM(struct iguana_info *coin,struct iguana_peer *addr,st req->datalen = datalen; req->txid = tx->txid; memcpy(req->serializeddata,data,datalen); - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + queue_enqueue("recvQ",&coin->recvQ,&req->DL); } #ifdef later @@ -526,7 +526,7 @@ void iguana_oldgotblockM(struct supernet_info *myinfo,struct iguana_info *coin,s } req->addr = addr; //if ( (bits256_cmp(origtxdata->zblock.RO.hash2,coin->blocks.hwmchain.RO.hash2) == 0 || req->zblock.mainchain == 0 || req->zblock.valid == 0 || req->zblock.txvalid == 0) && iguana_RTrawdata(coin,origtxdata->zblock.RO.hash2,0,&len,&numtx,1) == 0 ) - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + queue_enqueue("recvQ",&coin->recvQ,&req->DL); if ( 0 && strcmp("BTCD",coin->symbol) == 0 ) printf("%s Q.(%s)\n",coin->symbol,bits256_str(str,origtxdata->zblock.RO.hash2)); } else printf("nonz fpos.%d %s\n",txdata->zblock.fpos,bits256_str(str,origtxdata->zblock.RO.hash2)); @@ -755,7 +755,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru numtx = origtxdata->zblock.RO.txn_count; iguana_RTgotblock(coin,origtxdata->zblock.RO.hash2,data,&recvlen,&numtx); req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + queue_enqueue("recvQ",&coin->recvQ,&req->DL); return; } else if ( bundlei < coin->chain->bundlesize-1 ) @@ -780,7 +780,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru { printf("gotblockM no bp %s\n",bits256_str(str,origtxdata->zblock.RO.hash2)); req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + queue_enqueue("recvQ",&coin->recvQ,&req->DL); return; } for (i=numsaved=0; ichain->bundlesize; i++) @@ -791,7 +791,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru if ( (speculative= iguana_bundlestats_update(coin,&block,bp,bundlei,origtxdata,data,recvlen)) < 0 ) { req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + queue_enqueue("recvQ",&coin->recvQ,&req->DL); //printf("negative speculative return %s\n",bits256_str(str,origtxdata->zblock.RO.hash2)); return; } @@ -838,7 +838,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru // printf("DUP s.%d [%d:%d].(%s) %s n%d\n",numsaved,bp!=0?bp->hdrsi:-1,bundlei,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr,addr->pendblocks); } req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + queue_enqueue("recvQ",&coin->recvQ,&req->DL); return; } } @@ -850,7 +850,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru txdata->zblock.fpos = 0; copyflag = (coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0); req = iguana_recv_bundlereq(coin,addr,copyflag,H,data,recvlen,bp,bundlei,txdata); - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + queue_enqueue("recvQ",&coin->recvQ,&req->DL); if ( 0 && bp->hdrsi == 0 && strcmp("SYS",coin->symbol) == 0 ) printf("[%d:%d].s%d %s Q.(%s) %s\n",bp->hdrsi,bundlei,numsaved,coin->symbol,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr); if ( numsaved < coin->chain->bundlesize ) @@ -886,7 +886,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru else { req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + queue_enqueue("recvQ",&coin->recvQ,&req->DL); } } @@ -896,7 +896,7 @@ void iguana_gottxidsM(struct iguana_info *coin,struct iguana_peer *addr,bits256 //printf("got %d txids from %s\n",n,addr->ipaddr); req = iguana_bundlereq(coin,addr,'T',0,0); req->hashes = txids, req->n = n; - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + queue_enqueue("recvQ",&coin->recvQ,&req->DL); } int32_t iguana_gotheadersM(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_zblock *zblocks,int32_t n) @@ -948,7 +948,7 @@ int32_t iguana_gotheadersM(struct iguana_info *coin,struct iguana_peer *addr,str memcpy(req->blocks,&zblocks[i++ * coin->chain->bundlesize],coin->chain->bundlesize * sizeof(*zblocks)); req->n = coin->chain->bundlesize; HDRnet++; - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + queue_enqueue("recvQ",&coin->recvQ,&req->DL); } } else @@ -956,7 +956,7 @@ int32_t iguana_gotheadersM(struct iguana_info *coin,struct iguana_peer *addr,str req = iguana_bundlereq(coin,addr,'H',0,0); req->blocks = zblocks, req->n = n; HDRnet++; - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + queue_enqueue("recvQ",&coin->recvQ,&req->DL); zblocks = 0; } if ( zblocks != 0 ) @@ -984,7 +984,7 @@ void iguana_gotblockhashesM(struct iguana_info *coin,struct iguana_peer *addr,bi char str[65]; if ( 0 && n > 2 && addr != 0 ) printf("addr.%d %s [%d]\n",addr->rank,bits256_str(str,blockhashes[1]),n); - queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); + queue_enqueue("recvQ",&coin->recvQ,&req->DL); if ( strcmp("BTC",coin->symbol) != 0 ) { if ( n > coin->chain->bundlesize ) @@ -1061,7 +1061,7 @@ void iguana_bundlespeculate(struct iguana_info *coin,struct iguana_bundle *bp,in char str[65]; bits256_str(str,bp->hashes[0]); //fprintf(stderr,"Afound block -> %d %d hdr.%s\n",bp->bundleheight,coin->longestchain-coin->chain->bundlesize,str); bp->hdrtime = (uint32_t)time(NULL); - queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(str),1); + queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(str)); } } @@ -1451,7 +1451,7 @@ void iguana_autoextend(struct supernet_info *myinfo,struct iguana_info *coin,str if ( time(NULL) > bp->hdrtime+3 && newbp->speculative == 0 ) { bp->hdrtime = (uint32_t)time(NULL); - queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1); + queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr)); } //char str[65],str2[65]; printf("EXTEND last bundle %s/%s ht.%d\n",bits256_str(str,newbp->hashes[0]),bits256_str(str2,bp->nextbundlehash2),newbp->bundleheight); if ( newbp->queued == 0 ) @@ -1678,7 +1678,7 @@ struct iguana_bundlereq *iguana_recvblock(struct supernet_info *myinfo,struct ig coin->numcached++; if ( block != 0 ) block->queued = 1; - queue_enqueue("cacheQ",&coin->cacheQ,&req->DL,0); + queue_enqueue("cacheQ",&coin->cacheQ,&req->DL); return(0); } else if ( block != 0 && block->req == 0 ) @@ -1719,7 +1719,7 @@ struct iguana_bundlereq *iguana_recvblock(struct supernet_info *myinfo,struct ig { printf("reissue hdrs request for [%d]\n",bp->hdrsi); bp->hdrtime = (uint32_t)time(NULL); - queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1); + queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0]))); } if ( (block= iguana_blockhashset("recvblock",coin,-1,origblock->RO.hash2,1)) != 0 ) { @@ -1929,7 +1929,7 @@ int32_t iguana_processrecvQ(struct supernet_info *myinfo,struct iguana_info *coi { int32_t flag = 0; struct iguana_bundlereq *req; *newhwmp = 0; - while ( flag < IGUANA_MAXITERATIONS && coin->active != 0 && (req= queue_dequeue(&coin->recvQ,0)) != 0 ) + while ( flag < IGUANA_MAXITERATIONS && coin->active != 0 && (req= queue_dequeue(&coin->recvQ)) != 0 ) { if ( req->type != 'H' ) flag++; @@ -2004,18 +2004,18 @@ int32_t iguana_reqhdrs(struct iguana_info *coin) if ( bp->issuetime == 0 ) coin->numpendings++; init_hexbytes_noT(hashstr,bp->hashes[0].bytes,sizeof(bits256)); - queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1); + queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr)); if ( bp == coin->current ) { init_hexbytes_noT(hashstr,bp->hashes[0].bytes,sizeof(bits256)); - queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1); + queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr)); //printf("%s issue HWM HDRS [%d] %s\n",coin->symbol,bp->hdrsi,hashstr); if ( coin->blocks.hwmchain.height > 10 ) { bits256 hash2 = iguana_blockhash(coin,coin->blocks.hwmchain.height-10); init_hexbytes_noT(hashstr,hash2.bytes,sizeof(bits256)); //printf("%s issue HWM HDRS %d-10 %s\n",coin->symbol,coin->blocks.hwmchain.height,hashstr); - queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1); + queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr)); } } //printf("hdrsi.%d reqHDR.(%s) numhashes.%d\n",bp->hdrsi,hashstr,bp->numhashes); @@ -2087,7 +2087,7 @@ int32_t iguana_blockQ(char *argstr,struct iguana_info *coin,struct iguana_bundle if ( block->fpipbits == 0 && block->queued == 0 && block->req != 0 ) { block->queued = 1; - queue_enqueue("cacheQ",&coin->cacheQ,&block->req->DL,0); + queue_enqueue("cacheQ",&coin->cacheQ,&block->req->DL); block->req = 0; //char str2[65]; printf("already have.(%s)\n",bits256_str(str2,block->RO.hash2)); } @@ -2124,7 +2124,7 @@ int32_t iguana_blockQ(char *argstr,struct iguana_info *coin,struct iguana_bundle { if ( 1 && n > 200000 ) printf("%s %s %s [%d:%d] %d %s %d numranked.%d qsize.%d\n",coin->symbol,argstr,str,bp!=0?bp->hdrsi:-1,bundlei,req->height,bits256_str(str2,hash2),coin->blocks.recvblocks,coin->peers != 0 ? coin->peers->numranked : -1,queue_size(Q)); - while ( (ptr= queue_dequeue(Q,0)) != 0 ) + while ( (ptr= queue_dequeue(Q)) != 0 ) myfree(ptr,sizeof(*ptr)); coin->backlog = n*10 + 1000000; } else coin->backlog >>= 1; @@ -2133,7 +2133,7 @@ int32_t iguana_blockQ(char *argstr,struct iguana_info *coin,struct iguana_bundle //block->numrequests++; block->issued = now; } - queue_enqueue(str,Q,&req->DL,0); + queue_enqueue(str,Q,&req->DL); return(1); } else printf("null Q\n"); } //else printf("queueblock skip priority.%d bundlei.%d\n",bundlei,priority); @@ -2144,7 +2144,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) { uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(uint32_t)*32 + sizeof(bits256)]; struct iguana_block *block; struct iguana_blockreq *req=0; char *hashstr=0; bits256 hash2; - int32_t bundlei,priority,i,m,z,pend,limit,height=-1,datalen,flag = 0; + int32_t bundlei,priority,i,m,z,pend,limit,height=-1,datalen,flag = 0; struct stritem *hashitem; uint32_t now; struct iguana_bundle *bp; struct iguana_peer *ptr; if ( addr->msgcounts.verack == 0 ) return(0); @@ -2154,8 +2154,9 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) if ( iguana_needhdrs(coin) != 0 && addr->pendhdrs < IGUANA_MAXPENDHDRS ) { //printf("%s check hdrsQ\n",addr->ipaddr); - if ( (hashstr= queue_dequeue(&coin->hdrsQ,1)) != 0 ) + if ( (hashitem= queue_dequeue(&coin->hdrsQ)) != 0 ) { + hashstr = hashitem->str; if ( (datalen= iguana_gethdrs(coin,serialized,coin->chain->gethdrsmsg,hashstr)) > 0 ) { decode_hex(hash2.bytes,sizeof(hash2),hashstr); @@ -2187,8 +2188,9 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) //free_queueitem(hashstr); //return(flag); } else printf("datalen.%d from gethdrs\n",datalen); - free_queueitem(hashstr); + free(hashitem); hashstr = 0; + hashitem = 0; } } //if ( netBLOCKS > coin->MAXPEERS*coin->MAXPENDING ) @@ -2204,7 +2206,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) } priority = 1; pend = 0; - req = queue_dequeue(&coin->priorityQ,0); + req = queue_dequeue(&coin->priorityQ); if ( flag == 0 && req == 0 && addr->pendblocks < limit ) { priority = 0; @@ -2217,7 +2219,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) } } if ( pend < coin->MAXPENDINGREQUESTS*m ) - req = queue_dequeue(&coin->blocksQ,0); + req = queue_dequeue(&coin->blocksQ); } if ( req != 0 ) { diff --git a/iguana/iguana_spendvectors.c b/iguana/iguana_spendvectors.c index 660cb55b3..6ff55c034 100755 --- a/iguana/iguana_spendvectors.c +++ b/iguana/iguana_spendvectors.c @@ -772,7 +772,7 @@ void iguana_initfinal(struct supernet_info *myinfo,struct iguana_info *coin,bits if ( bits256_nonz(lastbundle) > 0 ) { init_hexbytes_noT(hashstr,lastbundle.bytes,sizeof(bits256)); - queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1); + queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr)); } for (i=0; ibundlescount-1; i++) { diff --git a/iguana/main.c b/iguana/main.c index 3ea2ccc12..c200878fd 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -190,10 +190,10 @@ int32_t iguana_jsonQ(struct supernet_info *myinfo,struct iguana_info *coin) if ( (ptr->retjsonstr= SuperNET_jsonstr(ptr->myinfo,ptr->jsonstr,ptr->remoteaddr,ptr->port)) == 0 ) ptr->retjsonstr = clonestr("{\"error\":\"null return from iguana_jsonstr\"}"); printf("COMMANDLINE_ARGFILE.(%s) -> (%s) %.0f\n",ptr->jsonstr,ptr->retjsonstr!=0?ptr->retjsonstr:"null return",OS_milliseconds()); - queue_enqueue("finishedQ",finishedQ,&ptr->DL,0); + queue_enqueue("finishedQ",finishedQ,&ptr->DL); return(1); } - if ( (ptr= queue_dequeue(finishedQ,0)) != 0 ) + if ( (ptr= queue_dequeue(finishedQ)) != 0 ) { if ( ptr->expired != 0 ) { @@ -204,14 +204,14 @@ int32_t iguana_jsonQ(struct supernet_info *myinfo,struct iguana_info *coin) } printf("garbage collection: expired.(%s)\n",ptr->jsonstr); myfree(ptr,ptr->allocsize); - } else queue_enqueue("finishedQ",finishedQ,&ptr->DL,0); + } else queue_enqueue("finishedQ",finishedQ,&ptr->DL); } - if ( (ptr= queue_dequeue(jsonQ,0)) != 0 ) + if ( (ptr= queue_dequeue(jsonQ)) != 0 ) { if ( (ptr->retjsonstr= SuperNET_jsonstr(ptr->myinfo,ptr->jsonstr,ptr->remoteaddr,ptr->port)) == 0 ) ptr->retjsonstr = clonestr("{\"error\":\"null return from iguana_jsonstr\"}"); //printf("finished.(%s) -> (%s) %.0f\n",ptr->jsonstr,ptr->retjsonstr!=0?ptr->retjsonstr:"null return",OS_milliseconds()); - queue_enqueue("finishedQ",finishedQ,&ptr->DL,0); + queue_enqueue("finishedQ",finishedQ,&ptr->DL); return(1); } return(0); @@ -234,7 +234,7 @@ char *iguana_blockingjsonstr(struct supernet_info *myinfo,struct iguana_info *co if ( coin == 0 || coin->FULLNODE < 0 || (coin->FULLNODE == 0 && coin->VALIDATENODE == 0) ) Q = &JSON_Q; else Q = &coin->jsonQ; - queue_enqueue("jsonQ",Q,&ptr->DL,0); + queue_enqueue("jsonQ",Q,&ptr->DL); while ( OS_milliseconds() < expiration ) { usleep(100); diff --git a/iguana/pangea_hand.c b/iguana/pangea_hand.c index 9cd6a671b..88fec043f 100755 --- a/iguana/pangea_hand.c +++ b/iguana/pangea_hand.c @@ -24,11 +24,11 @@ struct pangea_queueitem *pangea_queuefind(struct table_info *tp,int32_t waiteven int32_t iter; struct pangea_queueitem *ptr; for (iter=0; iter<2; iter++) { - while ( (ptr= queue_dequeue(&tp->stateQ[iter],0)) != 0 ) + while ( (ptr= queue_dequeue(&tp->stateQ[iter])) != 0 ) { if ( ptr->waitevent == waitevent ) return(ptr); - queue_enqueue("stateQ",&tp->stateQ[iter ^ 1],&ptr->DL,0); + queue_enqueue("stateQ",&tp->stateQ[iter ^ 1],&ptr->DL); } } return(0); @@ -42,7 +42,7 @@ void pangea_queuestate(struct table_info *tp,int32_t currentstate,int32_t waitev ptr->last = ptr->start = tai_now(); ptr->waitevent = waitevent; char str[65]; printf("table.%s current.%d -> wait.%d\n",bits256_str(str,tp->G.tablehash),currentstate,waitevent); - queue_enqueue("stateQ",&tp->stateQ[0],&ptr->DL,0); + queue_enqueue("stateQ",&tp->stateQ[0],&ptr->DL); } int32_t pangea_slotA(struct table_info *tp) { return(0); } @@ -383,7 +383,7 @@ int32_t pangea_queueprocess(struct supernet_info *myinfo,struct table_info *tp) //char str[65]; printf("queueprocess.(%s)\n",bits256_str(str,tp->G.tablehash)); for (iter=0; iter<2; iter++) { - while ( (ptr= queue_dequeue(&tp->stateQ[iter],0)) != 0 ) + while ( (ptr= queue_dequeue(&tp->stateQ[iter])) != 0 ) { retval = 0; diff = tai_diff(ptr->last,tai_now()); @@ -409,7 +409,7 @@ int32_t pangea_queueprocess(struct supernet_info *myinfo,struct table_info *tp) else { ptr->last = tai_now(); - queue_enqueue("stateQ",&tp->stateQ[iter ^ 1],&ptr->DL,0); + queue_enqueue("stateQ",&tp->stateQ[iter ^ 1],&ptr->DL); } } }