jl777 8 years ago
parent
commit
cef7bc0078
  1. 4
      basilisk/basilisk.c
  2. 4
      basilisk/basilisk_MSG.c
  3. 2
      basilisk/basilisk_ping.c
  4. 10
      crypto777/OS_portable.h
  5. 53
      crypto777/iguana_OS.c
  6. 4
      crypto777/iguana_utils.c
  7. 6
      iguana/iguana777.c
  8. 10
      iguana/iguana_accept.c
  9. 16
      iguana/iguana_bundles.c
  10. 20
      iguana/iguana_exchanges.c
  11. 26
      iguana/iguana_init.c
  12. 18
      iguana/iguana_peers.c
  13. 57
      iguana/iguana_recv.c
  14. 2
      iguana/iguana_spendvectors.c
  15. 12
      iguana/main.c
  16. 10
      iguana/pangea_hand.c

4
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) 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; 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; len = 0;
expand_ipbits(senderip,ptr->ipbits); 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); ipbits = (uint32_t)calc_ipbits(senderip);
else ipbits = myinfo->myaddr.myipbits; else ipbits = myinfo->myaddr.myipbits;
ptr = basilisk_p2pitem_create(coin,addr,type,ipbits,data,datalen); 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) int32_t basilisk_issued_purge(struct supernet_info *myinfo,int32_t timepad)

4
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); //printf("overwrite update of msg.[%d] <- datalen.%d\n",msg->datalen,datalen);
memcpy(msg->data,data,datalen); memcpy(msg->data,data,datalen);
if ( sendping != 0 ) 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); portable_mutex_unlock(&myinfo->messagemutex);
return(clonestr("{\"result\":\"message updated\"}")); 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 ) //if ( myinfo->NOTARY.RELAYID >= 0 )
// dpow_handler(myinfo,msg); // dpow_handler(myinfo,msg);
if ( sendping != 0 ) 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\"}")); return(clonestr("{\"result\":\"message added to hashtable\"}"));
} }

2
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) int32_t basilisk_ping_genMSG(struct supernet_info *myinfo,uint8_t *data,int32_t maxlen)
{ {
struct basilisk_message *msg; int32_t datalen = 0; 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++] = 1;
data[datalen++] = msg->keylen; data[datalen++] = msg->keylen;

10
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 allocitem { uint32_t allocsize,type; } PACKED;
struct queueitem { struct queueitem *next,*prev; 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 typedef struct queue
{ {
struct queueitem *list; struct queueitem *list;
@ -249,14 +251,14 @@ void OS_randombytes(uint8_t *x,long xlen);
long myallocated(uint8_t type,long change); long myallocated(uint8_t type,long change);
void *mycalloc(uint8_t type,int32_t n,long itemsize); void *mycalloc(uint8_t type,int32_t n,long itemsize);
void myfree(void *_ptr,long allocsize); 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 *myrealloc(uint8_t type,void *oldptr,long oldsize,long newsize);
void *myaligned_alloc(uint64_t allocsize); void *myaligned_alloc(uint64_t allocsize);
int32_t myaligned_free(void *ptr,long size); int32_t myaligned_free(void *ptr,long size);
void *queueitem(char *str); struct queueitem *queueitem(char *str);
void queue_enqueue(char *name,queue_t *queue,struct queueitem *origitem,int32_t offsetflag); 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_dequeue(queue_t *queue);//,int32_t offsetflag);
void *queue_delete(queue_t *queue,struct queueitem *copy,int32_t copysize,int32_t freeitem); void *queue_delete(queue_t *queue,struct queueitem *copy,int32_t copysize,int32_t freeitem);
void *queue_free(queue_t *queue); void *queue_free(queue_t *queue);
void *queue_clone(queue_t *clone,queue_t *queue,int32_t size); void *queue_clone(queue_t *clone,queue_t *queue,int32_t size);

53
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) void *mycalloc(uint8_t type,int32_t n,long itemsize)
{ {
#ifdef USE_MYCALLOC
//static portable_mutex_t MEMmutex; //static portable_mutex_t MEMmutex;
struct allocitem *item; int64_t allocsize = ((uint64_t)n * itemsize); struct allocitem *item; int64_t allocsize = ((uint64_t)n * itemsize);
if ( type == 0 && n == 0 && itemsize == 0 ) if ( type == 0 && n == 0 && itemsize == 0 )
@ -115,11 +116,14 @@ void *mycalloc(uint8_t type,int32_t n,long itemsize)
item->type = type; item->type = type;
//portable_mutex_unlock(&MEMmutex); //portable_mutex_unlock(&MEMmutex);
return((void *)((long)item + sizeof(*item))); 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); //portable_mutex_lock(&MEMmutex);
n = (uint32_t)strlen(str) + 1; n = (uint32_t)strlen(str) + 1;
allocsize = (uint32_t)(sizeof(struct queueitem) + n); allocsize = (uint32_t)(sizeof(struct queueitem) + n);
@ -136,9 +140,15 @@ void *queueitem(char *str)
memcpy(data,str,n); memcpy(data,str,n);
//printf("(%c) queueitem.%p itemdata.%p n.%d allocsize.%d\n",type,item,data,n,allocsize); //printf("(%c) queueitem.%p itemdata.%p n.%d allocsize.%d\n",type,item,data,n,allocsize);
//portable_mutex_unlock(&MEMmutex); //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) void _myfree(uint8_t type,int32_t origallocsize,void *origptr,int32_t allocsize)
{ {
//portable_mutex_lock(&MEMmutex); //portable_mutex_lock(&MEMmutex);
@ -171,12 +181,12 @@ void myfree(void *_ptr,long allocsize)
_myfree(item->type,item->allocsize,item,(uint32_t)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)); struct queueitem *item = (void *)((long)itemdata - sizeof(struct queueitem));
//printf("freeq item.%p itemdata.%p size.%d\n",item,itemdata,item->allocsize); //printf("freeq item.%p itemdata.%p size.%d\n",item,itemdata,item->allocsize);
_myfree(item->type,item->allocsize,item,item->allocsize); _myfree(item->type,item->allocsize,item,item->allocsize);
} }*/
void *myrealloc(uint8_t type,void *oldptr,long oldsize,long newsize) 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); 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); } 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); 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 ) if ( queue->name[0] == 0 && name != 0 && name[0] != 0 )
strcpy(queue->name,name);//,sizeof(queue->name)); 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); //fprintf(stderr,"enqueue.(%s) %p offset.%d\n",queue->name,origitem,offsetflag);
lock_queue(queue); 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); DL_APPEND(queue->list,item);
portable_mutex_unlock(&queue->mutex); portable_mutex_unlock(&queue->mutex);
//printf("queue_enqueue name.(%s) origitem.%p append.%p list.%p\n",name,origitem,item,queue->list); //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; struct queueitem *item = 0;
lock_queue(queue); lock_queue(queue);
@ -264,9 +280,10 @@ void *queue_dequeue(queue_t *queue,int32_t offsetflag)
DL_DELETE(queue->list,item); DL_DELETE(queue->list,item);
} }
portable_mutex_unlock(&queue->mutex); portable_mutex_unlock(&queue->mutex);
if ( item != 0 && offsetflag != 0 ) //if ( item != 0 && offsetflag != 0 )
return((void *)((long)item + sizeof(struct queueitem))); // return((void *)((long)item + sizeof(struct queueitem)));
else return(item); //else
return(item);
} }
void *queue_delete(queue_t *queue,struct queueitem *copy,int32_t copysize,int32_t freeitem) 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)); ptr = mycalloc('c',1,sizeof(*ptr));
memcpy(ptr,item,size); 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); //printf("name.(%s) dequeue.%p list.%p\n",queue->name,item,queue->list);
} }

4
crypto777/iguana_utils.c

@ -268,7 +268,7 @@ void iguana_launcher(void *ptr)
t->funcp(t->arg); t->funcp(t->arg);
if ( coin != 0 ) if ( coin != 0 )
coin->Terminated[t->type % (sizeof(coin->Terminated)/sizeof(*coin->Terminated))]++; 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) 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); retval = OS_thread_create(&t->handle,NULL,(void *)iguana_launcher,(void *)t);
if ( retval != 0 ) if ( retval != 0 )
printf("error launching %s\n",t->name); 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 ) if ( (rand() % 100000) == 0 && coin != 0 )
printf("terminated.%d launched.%d terminate.%p\n",coin->Terminated[t->type],coin->Launched[t->type],t); printf("terminated.%d launched.%d terminate.%p\n",coin->Terminated[t->type],coin->Launched[t->type],t);

6
iguana/iguana777.c

@ -266,7 +266,7 @@ void iguana_emitQ(struct iguana_info *coin,struct iguana_bundle *bp)
ptr->type = 'E'; ptr->type = 'E';
ptr->starttime = (uint32_t)time(NULL); ptr->starttime = (uint32_t)time(NULL);
//printf("%s EMIT.%d[%d] emitfinish.%u\n",coin->symbol,ptr->hdrsi,bp->n,bp->emitfinish); //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) 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; ptr->timelimit = timelimit;
coin->numbundlesQ++; 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); // 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 else
{ {
@ -766,7 +766,7 @@ void iguana_helper(void *arg)
n = queue_size(&bundlesQ); n = queue_size(&bundlesQ);
for (iter=0; iter<n; iter++) for (iter=0; iter<n; iter++)
{ {
if ( (ptr= queue_dequeue(&bundlesQ,0)) != 0 ) if ( (ptr= queue_dequeue(&bundlesQ)) != 0 )
{ {
idle = 0; idle = 0;
coin = ptr->coin; coin = ptr->coin;

10
iguana/iguana_accept.c

@ -134,7 +134,7 @@ void iguana_acceptloop(void *args)
ptr->sock = sock; ptr->sock = sock;
ptr->port = cli_addr.sin_port; ptr->port = cli_addr.sin_port;
printf("queue PENDING ACCEPTS\n"); printf("queue PENDING ACCEPTS\n");
queue_enqueue("acceptQ",&coin->acceptQ,&ptr->DL,0); queue_enqueue("acceptQ",&coin->acceptQ,&ptr->DL);
} }
else else
{ {
@ -152,7 +152,7 @@ void iguana_acceptloop(void *args)
int32_t iguana_pendingaccept(struct iguana_info *coin) int32_t iguana_pendingaccept(struct iguana_info *coin)
{ {
struct iguana_accept *ptr; char ipaddr[64]; struct iguana_peer *addr; 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 ) 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); iguana_launch(coin,"accept",iguana_dedicatedglue,addr,IGUANA_CONNTHREAD);
myfree(ptr,sizeof(*ptr)); myfree(ptr,sizeof(*ptr));
return(1); return(1);
} else queue_enqueue("requeue_acceptQ",&coin->acceptQ,&ptr->DL,0); } else queue_enqueue("requeue_acceptQ",&coin->acceptQ,&ptr->DL);
} }
return(0); return(0);
} }
@ -185,13 +185,13 @@ void iguana_msgrequestQ(struct iguana_info *coin,struct iguana_peer *addr,int32_
msg->addr = addr; msg->addr = addr;
msg->hash2 = hash2; msg->hash2 = hash2;
msg->type = type; 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) 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; 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; flag = 1;
if ( msg->addr != 0 ) if ( msg->addr != 0 )

16
iguana/iguana_bundles.c

@ -685,7 +685,7 @@ int32_t iguana_bundleissuemissing(struct supernet_info *myinfo,struct iguana_inf
req->bp = bp; req->bp = bp;
req->height = bp->bundleheight + i; req->height = bp->bundleheight + i;
req->bundlei = i; req->bundlei = i;
queue_enqueue("missing",&coin->priorityQ,&req->DL,0); queue_enqueue("missing",&coin->priorityQ,&req->DL);
bp->issued[i] = 1; bp->issued[i] = 1;
n++; n++;
if ( 0 && bp == coin->current ) 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->bp = bp;
req->height = bp->bundleheight + i; req->height = bp->bundleheight + i;
req->bundlei = i; req->bundlei = i;
queue_enqueue("blast",&coin->priorityQ,&req->DL,0); queue_enqueue("blast",&coin->priorityQ,&req->DL);
} }
} }
if ( n > m ) 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))) ) 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); 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 ) 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 ) if ( GETBIT(bp->haveblock,i) == 0 )
bp->issued[i] = 0; bp->issued[i] = 0;
bp->hdrtime = (uint32_t)time(NULL); 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.); iguana_bundleissuemissing(myinfo,coin,bp,3,3.);
/*if ( bp == coin->current ) /*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); 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 ) 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)); myfree(breq,sizeof(*breq));
//printf("cleared priorityQ\n"); //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); coin->stuckiters = (int32_t)(lag/coin->MAXSTUCKTIME);
if ( coin->stuckiters > 2 ) if ( coin->stuckiters > 2 )
{ {
while ( (breq= queue_dequeue(&coin->blocksQ,0)) != 0 ) while ( (breq= queue_dequeue(&coin->blocksQ)) != 0 )
myfree(breq,sizeof(*breq)); myfree(breq,sizeof(*breq));
while ( (breq= queue_dequeue(&coin->priorityQ,0)) != 0 ) while ( (breq= queue_dequeue(&coin->priorityQ)) != 0 )
myfree(breq,sizeof(*breq)); myfree(breq,sizeof(*breq));
for (i=0; i<bp->n; i++) for (i=0; i<bp->n; i++)
{ {
@ -1562,7 +1562,7 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch
coin->estsize = estsize; coin->estsize = estsize;
if ( queue_size(&coin->priorityQ) > 10000 ) 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)); myfree(breq,sizeof(*breq));
//printf("cleared priorityQ\n"); //printf("cleared priorityQ\n");
} }

20
iguana/iguana_exchanges.c

@ -754,7 +754,7 @@ void exchanges777_loop(void *ptr)
PAX_idle(myinfo); PAX_idle(myinfo);
flag = retval = 0; flag = retval = 0;
retstr = 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); //printf("dequeued %s.%c\n",exchange->name,req->func);
if ( req->dead == 0 ) if ( req->dead == 0 )
@ -782,7 +782,7 @@ void exchanges777_loop(void *ptr)
// queue_enqueue("Xpending",&exchange->pendingQ,&req->DL,0), flag++; // queue_enqueue("Xpending",&exchange->pendingQ,&req->DL,0), flag++;
//else //else
if ( retval == EXCHANGE777_REQUEUE ) if ( retval == EXCHANGE777_REQUEUE )
queue_enqueue("requeue",&exchange->requestQ,&req->DL,0); queue_enqueue("requeue",&exchange->requestQ,&req->DL);
else else
{ {
printf("exchanges777_process: illegal retval.%d\n",retval); printf("exchanges777_process: illegal retval.%d\n",retval);
@ -805,7 +805,7 @@ void exchanges777_loop(void *ptr)
iguana_statemachineupdate(myinfo,exchange); iguana_statemachineupdate(myinfo,exchange);
//printf("InstantDEX call update\n"); //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); //printf("check %s pricesQ (%s %s)\n",exchange->name,req->base,req->rel);
if ( req->dead == 0 ) 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); //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); 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 else
{ {
@ -843,12 +843,12 @@ struct exchange_request *exchanges777_baserelfind(struct exchange_info *exchange
{ {
struct exchange_request PAD,*req,*retreq=0; struct exchange_request PAD,*req,*retreq=0;
memset(&PAD,0,sizeof(PAD)); memset(&PAD,0,sizeof(PAD));
queue_enqueue("pricesQ",&exchange->pricesQ,&PAD.DL,0); queue_enqueue("pricesQ",&exchange->pricesQ,&PAD.DL);
while ( (req= queue_dequeue(&exchange->pricesQ,0)) != 0 && req != &PAD ) 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) ) 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; retreq = req;
queue_enqueue("pricesQ",&exchange->pricesQ,&req->DL,0); queue_enqueue("pricesQ",&exchange->pricesQ,&req->DL);
} }
return(retreq); return(retreq);
} }
@ -875,7 +875,7 @@ char *exchanges777_submit(struct exchange_info *exchange,struct exchange_request
maxseconds = EXCHANGES777_DEFAULT_TIMEOUT; maxseconds = EXCHANGES777_DEFAULT_TIMEOUT;
retstrp = req->retstrp; retstrp = req->retstrp;
//printf("submit to %p\n",&exchange->requestQ); //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; i<maxseconds; i++) for (i=0; i<maxseconds; i++)
{ {
if ( retstrp != 0 && (retstr= *retstrp) != 0 ) if ( retstrp != 0 && (retstr= *retstrp) != 0 )
@ -947,7 +947,7 @@ char *exchanges777_Qprices(struct exchange_info *exchange,char *base,char *rel,i
{ {
req->func = 'M'; req->func = 'M';
//printf("Monitor.%s (%s %s) invert.%d\n",exchange->name,base,rel,req->invert); //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\"}")); 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); //printf("got %d quotes from %s\n",n,addr->ipaddr);
req = iguana_bundlereq(coin,addr,'Q',0,0); req = iguana_bundlereq(coin,addr,'Q',0,0);
req->hashes = quotes, req->n = n; 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) struct exchange_info *exchange_create(char *exchangestr,cJSON *argjson)

26
iguana/iguana_init.c

@ -17,12 +17,14 @@
void iguana_initQ(queue_t *Q,char *name) void iguana_initQ(queue_t *Q,char *name)
{ {
char *tst,*str = "need to init each Q when single threaded"; struct stritem *tst,*item;
memset(Q,0,sizeof(*Q)); memset(Q,0,sizeof(*Q));
item = calloc(1,sizeof(*item)+100);
strcpy(item->str,"hello, world");
strcpy(Q->name,name); strcpy(Q->name,name);
queue_enqueue(name,Q,queueitem(str),1); queue_enqueue(name,Q,&item->DL);
if ( (tst= queue_dequeue(Q,1)) != 0 ) if ( (tst= queue_dequeue(Q)) != 0 )
free_queueitem(tst); free(tst);
} }
void iguana_initQs(struct iguana_info *coin) void iguana_initQs(struct iguana_info *coin)
@ -470,7 +472,7 @@ void iguana_blockspurge(struct iguana_info *coin)
void iguana_coinpurge(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; saved = coin->active, coin->active = 0;
coin->started = 0; coin->started = 0;
while ( coin->idletime == 0 && coin->emitbusy > 0 ) while ( coin->idletime == 0 && coin->emitbusy > 0 )
@ -479,19 +481,19 @@ void iguana_coinpurge(struct iguana_info *coin)
sleep(1); sleep(1);
} }
coin->RTgenesis = 0; coin->RTgenesis = 0;
while ( (ptr= queue_dequeue(&bundlesQ,0)) != 0 ) while ( (ptr= queue_dequeue(&bundlesQ)) != 0 )
myfree(ptr,ptr->allocsize); myfree(ptr,ptr->allocsize);
if ( 1 ) if ( 1 )
{ {
while ( (hashstr= queue_dequeue(&coin->hdrsQ,1)) != 0 ) while ( (hashitem= queue_dequeue(&coin->hdrsQ)) != 0 )
free_queueitem(hashstr); free(hashitem);
while ( (breq= queue_dequeue(&coin->blocksQ,0)) != 0 ) while ( (breq= queue_dequeue(&coin->blocksQ)) != 0 )
myfree(breq,sizeof(*breq)); myfree(breq,sizeof(*breq));
while ( (breq= queue_dequeue(&coin->priorityQ,0)) != 0 ) while ( (breq= queue_dequeue(&coin->priorityQ)) != 0 )
myfree(breq,sizeof(*breq)); myfree(breq,sizeof(*breq));
while ( (req= queue_dequeue(&coin->cacheQ,0)) != 0 ) while ( (req= queue_dequeue(&coin->cacheQ)) != 0 )
myfree(req,req->allocsize); myfree(req,req->allocsize);
while ( (req= queue_dequeue(&coin->recvQ,0)) != 0 ) while ( (req= queue_dequeue(&coin->recvQ)) != 0 )
{ {
if ( req->blocks != 0 ) if ( req->blocks != 0 )
myfree(req->blocks,sizeof(*req->blocks) * req->n), req->blocks = 0; myfree(req->blocks,sizeof(*req->blocks) * req->n), req->blocks = 0;

18
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); memcpy(packet->serialized,serialized,datalen);
if ( 0 && addr->supernet != 0 ) if ( 0 && addr->supernet != 0 )
printf("%p queue send.(%s) %d to (%s)\n",packet,serialized+4,datalen,addr->ipaddr); 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); 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) 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 ) if ( coin->virtualchain != 0 || coin->peers == 0 )
return(0); return(0);
if ( ipaddr != 0 && ipaddr[0] != 0 && coin->peers != 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); return(0);
} }
//printf("%s Q possible.(%s)\n",coin->symbol,ipaddr); //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)); return((uint32_t)time(NULL));
} }
else if ( iguana_pendingaccept(coin) != 0 ) else if ( iguana_pendingaccept(coin) != 0 )
return((uint32_t)time(NULL)); 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)); return((uint32_t)time(NULL));
safecopy(_ipaddr,ipaddr,sizeof(_ipaddr)); safecopy(_ipaddr,sitem->str,sizeof(_ipaddr));
free_queueitem(ipaddr); free(sitem);
ipaddr = _ipaddr; ipaddr = _ipaddr;
#ifdef IGUANA_DISABLEPEERS #ifdef IGUANA_DISABLEPEERS
if ( strcmp(ipaddr,"127.0.0.1") != 0 ) 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) int32_t iguana_pollsendQ(struct iguana_info *coin,struct iguana_peer *addr)
{ {
struct iguana_packet *packet; 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) ) 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); 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 else
{ {
//printf("embargo.x %llu %f\n",(long long)packet->embargo.x,tai_diff(packet->embargo,tai_now())); //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); return(0);
@ -1226,7 +1226,7 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin,
run = 0; run = 0;
while ( addr->usock >= 0 && addr->dead == 0 && coin->peers->shuttingdown == 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 ) if ( req->datalen != 0 )
{ {

57
iguana/iguana_recv.c

@ -185,7 +185,7 @@ void iguana_gotunconfirmedM(struct iguana_info *coin,struct iguana_peer *addr,st
req->datalen = datalen; req->datalen = datalen;
req->txid = tx->txid; req->txid = tx->txid;
memcpy(req->serializeddata,data,datalen); memcpy(req->serializeddata,data,datalen);
queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); queue_enqueue("recvQ",&coin->recvQ,&req->DL);
} }
#ifdef later #ifdef later
@ -526,7 +526,7 @@ void iguana_oldgotblockM(struct supernet_info *myinfo,struct iguana_info *coin,s
} }
req->addr = addr; 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 ) //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 ) if ( 0 && strcmp("BTCD",coin->symbol) == 0 )
printf("%s Q.(%s)\n",coin->symbol,bits256_str(str,origtxdata->zblock.RO.hash2)); 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)); } 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; numtx = origtxdata->zblock.RO.txn_count;
iguana_RTgotblock(coin,origtxdata->zblock.RO.hash2,data,&recvlen,&numtx); iguana_RTgotblock(coin,origtxdata->zblock.RO.hash2,data,&recvlen,&numtx);
req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); 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; return;
} }
else if ( bundlei < coin->chain->bundlesize-1 ) 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)); 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); 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; return;
} }
for (i=numsaved=0; i<coin->chain->bundlesize; i++) for (i=numsaved=0; i<coin->chain->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 ) 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); 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)); //printf("negative speculative return %s\n",bits256_str(str,origtxdata->zblock.RO.hash2));
return; 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); // 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); 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; return;
} }
} }
@ -850,7 +850,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru
txdata->zblock.fpos = 0; txdata->zblock.fpos = 0;
copyflag = (coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0); copyflag = (coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0);
req = iguana_recv_bundlereq(coin,addr,copyflag,H,data,recvlen,bp,bundlei,txdata); 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 ) 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); 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 ) if ( numsaved < coin->chain->bundlesize )
@ -886,7 +886,7 @@ void iguana_gotblockM(struct supernet_info *myinfo,struct iguana_info *coin,stru
else else
{ {
req = iguana_recv_bundlereq(coin,addr,0,H,data,recvlen,0,-1,origtxdata); 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); //printf("got %d txids from %s\n",n,addr->ipaddr);
req = iguana_bundlereq(coin,addr,'T',0,0); req = iguana_bundlereq(coin,addr,'T',0,0);
req->hashes = txids, req->n = n; 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) 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)); memcpy(req->blocks,&zblocks[i++ * coin->chain->bundlesize],coin->chain->bundlesize * sizeof(*zblocks));
req->n = coin->chain->bundlesize; req->n = coin->chain->bundlesize;
HDRnet++; HDRnet++;
queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); queue_enqueue("recvQ",&coin->recvQ,&req->DL);
} }
} }
else 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 = iguana_bundlereq(coin,addr,'H',0,0);
req->blocks = zblocks, req->n = n; req->blocks = zblocks, req->n = n;
HDRnet++; HDRnet++;
queue_enqueue("recvQ",&coin->recvQ,&req->DL,0); queue_enqueue("recvQ",&coin->recvQ,&req->DL);
zblocks = 0; zblocks = 0;
} }
if ( zblocks != 0 ) if ( zblocks != 0 )
@ -984,7 +984,7 @@ void iguana_gotblockhashesM(struct iguana_info *coin,struct iguana_peer *addr,bi
char str[65]; char str[65];
if ( 0 && n > 2 && addr != 0 ) if ( 0 && n > 2 && addr != 0 )
printf("addr.%d %s [%d]\n",addr->rank,bits256_str(str,blockhashes[1]),n); 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 ( strcmp("BTC",coin->symbol) != 0 )
{ {
if ( n > coin->chain->bundlesize ) 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]); 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); //fprintf(stderr,"Afound block -> %d %d hdr.%s\n",bp->bundleheight,coin->longestchain-coin->chain->bundlesize,str);
bp->hdrtime = (uint32_t)time(NULL); 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 ) if ( time(NULL) > bp->hdrtime+3 && newbp->speculative == 0 )
{ {
bp->hdrtime = (uint32_t)time(NULL); 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); //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 ) if ( newbp->queued == 0 )
@ -1678,7 +1678,7 @@ struct iguana_bundlereq *iguana_recvblock(struct supernet_info *myinfo,struct ig
coin->numcached++; coin->numcached++;
if ( block != 0 ) if ( block != 0 )
block->queued = 1; block->queued = 1;
queue_enqueue("cacheQ",&coin->cacheQ,&req->DL,0); queue_enqueue("cacheQ",&coin->cacheQ,&req->DL);
return(0); return(0);
} }
else if ( block != 0 && block->req == 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); printf("reissue hdrs request for [%d]\n",bp->hdrsi);
bp->hdrtime = (uint32_t)time(NULL); 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 ) 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; int32_t flag = 0; struct iguana_bundlereq *req;
*newhwmp = 0; *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' ) if ( req->type != 'H' )
flag++; flag++;
@ -2004,18 +2004,18 @@ int32_t iguana_reqhdrs(struct iguana_info *coin)
if ( bp->issuetime == 0 ) if ( bp->issuetime == 0 )
coin->numpendings++; coin->numpendings++;
init_hexbytes_noT(hashstr,bp->hashes[0].bytes,sizeof(bits256)); 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 ) if ( bp == coin->current )
{ {
init_hexbytes_noT(hashstr,bp->hashes[0].bytes,sizeof(bits256)); 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); //printf("%s issue HWM HDRS [%d] %s\n",coin->symbol,bp->hdrsi,hashstr);
if ( coin->blocks.hwmchain.height > 10 ) if ( coin->blocks.hwmchain.height > 10 )
{ {
bits256 hash2 = iguana_blockhash(coin,coin->blocks.hwmchain.height-10); bits256 hash2 = iguana_blockhash(coin,coin->blocks.hwmchain.height-10);
init_hexbytes_noT(hashstr,hash2.bytes,sizeof(bits256)); init_hexbytes_noT(hashstr,hash2.bytes,sizeof(bits256));
//printf("%s issue HWM HDRS %d-10 %s\n",coin->symbol,coin->blocks.hwmchain.height,hashstr); //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); //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 ) if ( block->fpipbits == 0 && block->queued == 0 && block->req != 0 )
{ {
block->queued = 1; block->queued = 1;
queue_enqueue("cacheQ",&coin->cacheQ,&block->req->DL,0); queue_enqueue("cacheQ",&coin->cacheQ,&block->req->DL);
block->req = 0; block->req = 0;
//char str2[65]; printf("already have.(%s)\n",bits256_str(str2,block->RO.hash2)); //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 ) 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)); 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)); myfree(ptr,sizeof(*ptr));
coin->backlog = n*10 + 1000000; coin->backlog = n*10 + 1000000;
} else coin->backlog >>= 1; } else coin->backlog >>= 1;
@ -2133,7 +2133,7 @@ int32_t iguana_blockQ(char *argstr,struct iguana_info *coin,struct iguana_bundle
//block->numrequests++; //block->numrequests++;
block->issued = now; block->issued = now;
} }
queue_enqueue(str,Q,&req->DL,0); queue_enqueue(str,Q,&req->DL);
return(1); return(1);
} else printf("null Q\n"); } else printf("null Q\n");
} //else printf("queueblock skip priority.%d bundlei.%d\n",bundlei,priority); } //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)]; 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; 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; uint32_t now; struct iguana_bundle *bp; struct iguana_peer *ptr;
if ( addr->msgcounts.verack == 0 ) if ( addr->msgcounts.verack == 0 )
return(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 ) if ( iguana_needhdrs(coin) != 0 && addr->pendhdrs < IGUANA_MAXPENDHDRS )
{ {
//printf("%s check hdrsQ\n",addr->ipaddr); //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 ) if ( (datalen= iguana_gethdrs(coin,serialized,coin->chain->gethdrsmsg,hashstr)) > 0 )
{ {
decode_hex(hash2.bytes,sizeof(hash2),hashstr); decode_hex(hash2.bytes,sizeof(hash2),hashstr);
@ -2187,7 +2188,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr)
//free_queueitem(hashstr); //free_queueitem(hashstr);
//return(flag); //return(flag);
} else printf("datalen.%d from gethdrs\n",datalen); } else printf("datalen.%d from gethdrs\n",datalen);
free_queueitem(hashstr); free(hashitem);
hashstr = 0; hashstr = 0;
} }
} }
@ -2204,7 +2205,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr)
} }
priority = 1; priority = 1;
pend = 0; pend = 0;
req = queue_dequeue(&coin->priorityQ,0); req = queue_dequeue(&coin->priorityQ);
if ( flag == 0 && req == 0 && addr->pendblocks < limit ) if ( flag == 0 && req == 0 && addr->pendblocks < limit )
{ {
priority = 0; priority = 0;
@ -2217,7 +2218,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr)
} }
} }
if ( pend < coin->MAXPENDINGREQUESTS*m ) if ( pend < coin->MAXPENDINGREQUESTS*m )
req = queue_dequeue(&coin->blocksQ,0); req = queue_dequeue(&coin->blocksQ);
} }
if ( req != 0 ) if ( req != 0 )
{ {

2
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 ) if ( bits256_nonz(lastbundle) > 0 )
{ {
init_hexbytes_noT(hashstr,lastbundle.bytes,sizeof(bits256)); 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; i<coin->bundlescount-1; i++) for (i=0; i<coin->bundlescount-1; i++)
{ {

12
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 ) if ( (ptr->retjsonstr= SuperNET_jsonstr(ptr->myinfo,ptr->jsonstr,ptr->remoteaddr,ptr->port)) == 0 )
ptr->retjsonstr = clonestr("{\"error\":\"null return from iguana_jsonstr\"}"); 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()); 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); return(1);
} }
if ( (ptr= queue_dequeue(finishedQ,0)) != 0 ) if ( (ptr= queue_dequeue(finishedQ)) != 0 )
{ {
if ( ptr->expired != 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); printf("garbage collection: expired.(%s)\n",ptr->jsonstr);
myfree(ptr,ptr->allocsize); 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 ) if ( (ptr->retjsonstr= SuperNET_jsonstr(ptr->myinfo,ptr->jsonstr,ptr->remoteaddr,ptr->port)) == 0 )
ptr->retjsonstr = clonestr("{\"error\":\"null return from iguana_jsonstr\"}"); 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()); //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(1);
} }
return(0); 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) ) if ( coin == 0 || coin->FULLNODE < 0 || (coin->FULLNODE == 0 && coin->VALIDATENODE == 0) )
Q = &JSON_Q; Q = &JSON_Q;
else Q = &coin->jsonQ; else Q = &coin->jsonQ;
queue_enqueue("jsonQ",Q,&ptr->DL,0); queue_enqueue("jsonQ",Q,&ptr->DL);
while ( OS_milliseconds() < expiration ) while ( OS_milliseconds() < expiration )
{ {
usleep(100); usleep(100);

10
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; int32_t iter; struct pangea_queueitem *ptr;
for (iter=0; iter<2; iter++) 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 ) if ( ptr->waitevent == waitevent )
return(ptr); return(ptr);
queue_enqueue("stateQ",&tp->stateQ[iter ^ 1],&ptr->DL,0); queue_enqueue("stateQ",&tp->stateQ[iter ^ 1],&ptr->DL);
} }
} }
return(0); 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->last = ptr->start = tai_now();
ptr->waitevent = waitevent; ptr->waitevent = waitevent;
char str[65]; printf("table.%s current.%d -> wait.%d\n",bits256_str(str,tp->G.tablehash),currentstate,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); } 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)); //char str[65]; printf("queueprocess.(%s)\n",bits256_str(str,tp->G.tablehash));
for (iter=0; iter<2; iter++) 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; retval = 0;
diff = tai_diff(ptr->last,tai_now()); diff = tai_diff(ptr->last,tai_now());
@ -409,7 +409,7 @@ int32_t pangea_queueprocess(struct supernet_info *myinfo,struct table_info *tp)
else else
{ {
ptr->last = tai_now(); ptr->last = tai_now();
queue_enqueue("stateQ",&tp->stateQ[iter ^ 1],&ptr->DL,0); queue_enqueue("stateQ",&tp->stateQ[iter ^ 1],&ptr->DL);
} }
} }
} }

Loading…
Cancel
Save