jl777 8 years ago
parent
commit
4188328572
  1. 19
      basilisk/basilisk.c
  2. 9
      basilisk/basilisk_MSG.c

19
basilisk/basilisk.c

@ -899,33 +899,22 @@ int32_t basilisk_issued_purge(struct supernet_info *myinfo,int32_t timepad)
void basilisk_iteration(struct supernet_info *myinfo) void basilisk_iteration(struct supernet_info *myinfo)
{ {
struct iguana_info *virt,*tmpcoin,*notary; struct basilisk_message *msg,*tmpmsg; uint32_t now; int32_t maxmillis,flag=0; struct iguana_info *notary; uint32_t now;
now = (uint32_t)time(NULL); now = (uint32_t)time(NULL);
notary = iguana_coinfind("NOTARY"); notary = iguana_coinfind("NOTARY");
portable_mutex_lock(&myinfo->messagemutex);
HASH_ITER(hh,myinfo->messagetable,msg,tmpmsg)
{
if ( now > msg->expiration )
{
printf("delete expired message.%p QUEUEITEMS.%d\n",msg,QUEUEITEMS);
HASH_DELETE(hh,myinfo->messagetable,msg);
QUEUEITEMS--;
free(msg);
}
}
portable_mutex_unlock(&myinfo->messagemutex);
if ( myinfo->NOTARY.RELAYID >= 0 ) if ( myinfo->NOTARY.RELAYID >= 0 )
{ {
basilisk_ping_send(myinfo,notary); basilisk_ping_send(myinfo,notary);
if ( notary != 0 ) /*if ( notary != 0 )
{ {
struct iguana_info *virt,*tmpcoin; int32_t maxmillis;
maxmillis = (1000 / (myinfo->allcoins_numvirts + 1)) + 1; maxmillis = (1000 / (myinfo->allcoins_numvirts + 1)) + 1;
HASH_ITER(hh,myinfo->allcoins,virt,tmpcoin) HASH_ITER(hh,myinfo->allcoins,virt,tmpcoin)
{ {
if ( virt->started != 0 && virt->active != 0 && virt->virtualchain != 0 ) if ( virt->started != 0 && virt->active != 0 && virt->virtualchain != 0 )
gecko_iteration(myinfo,notary,virt,maxmillis), flag++; gecko_iteration(myinfo,notary,virt,maxmillis), flag++;
} }
} }*/
} }
else if ( myinfo->expiration != 0 ) else if ( myinfo->expiration != 0 )
{ {

9
basilisk/basilisk_MSG.c

@ -149,7 +149,7 @@ int32_t basilisk_msgcmp(struct basilisk_message *msg,int32_t width,uint32_t chan
char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_t msgid,bits256 srchash,bits256 desthash,int32_t origwidth) char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_t msgid,bits256 srchash,bits256 desthash,int32_t origwidth)
{ {
uint8_t key[BASILISK_KEYSIZE]; int32_t allflag,i,keylen,width; cJSON *msgjson,*item,*retjson,*array; bits256 zero; struct basilisk_message *msg,*tmpmsg; uint8_t key[BASILISK_KEYSIZE]; int32_t allflag,i,keylen,width; cJSON *msgjson,*item,*retjson,*array; bits256 zero; struct basilisk_message *msg,*tmpmsg; uint32_t now = (uint32_t)time(NULL);
memset(zero.bytes,0,sizeof(zero)); memset(zero.bytes,0,sizeof(zero));
if ( (width= origwidth) > 3600 ) if ( (width= origwidth) > 3600 )
width = 3600; width = 3600;
@ -160,6 +160,13 @@ char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_
portable_mutex_lock(&myinfo->messagemutex); portable_mutex_lock(&myinfo->messagemutex);
HASH_ITER(hh,myinfo->messagetable,msg,tmpmsg) HASH_ITER(hh,myinfo->messagetable,msg,tmpmsg)
{ {
if ( now > msg->expiration )
{
printf("delete expired message.%p QUEUEITEMS.%d\n",msg,QUEUEITEMS);
HASH_DELETE(hh,myinfo->messagetable,msg);
QUEUEITEMS--;
free(msg);
}
if ( allflag != 0 || (msg->broadcast != 0 && basilisk_msgcmp(msg,origwidth,channel,msgid,zero,zero) == 0) ) if ( allflag != 0 || (msg->broadcast != 0 && basilisk_msgcmp(msg,origwidth,channel,msgid,zero,zero) == 0) )
if ( (msgjson= basilisk_msgjson(msg,msg->key,msg->keylen)) != 0 ) if ( (msgjson= basilisk_msgjson(msg,msg->key,msg->keylen)) != 0 )
jaddi(array,msgjson); jaddi(array,msgjson);

Loading…
Cancel
Save