Browse Source

test

etomic
jl777 8 years ago
parent
commit
f652f4ef00
  1. 2
      iguana/dPoW.h
  2. 4
      iguana/dpow/dpow_network.c
  3. 20
      iguana/dpow/dpow_rpc.c
  4. 6
      iguana/iguana_notary.c

2
iguana/dPoW.h

@ -134,7 +134,7 @@ struct dpow_info
uint32_t SRCREALTIME,destupdated,srcconfirms,numdesttx,numsrctx,lastsplit,cancelratify; uint32_t SRCREALTIME,destupdated,srcconfirms,numdesttx,numsrctx,lastsplit,cancelratify;
int32_t lastheight,maxblocks,SRCHEIGHT,SHORTFLAG,ratifying; int32_t lastheight,maxblocks,SRCHEIGHT,SHORTFLAG,ratifying;
struct pax_transaction *PAX; struct pax_transaction *PAX;
portable_mutex_t mutex; portable_mutex_t paxmutex,dpowmutex,dexmutex;
uint32_t ipbits[64],numipbits; uint32_t ipbits[64],numipbits;
struct dpow_block **blocks; struct dpow_block **blocks;
}; };

4
iguana/dpow/dpow_network.c

@ -766,7 +766,9 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo
np->version0 = DPOW_VERSION & 0xff; np->version0 = DPOW_VERSION & 0xff;
np->version1 = (DPOW_VERSION >> 8) & 0xff; np->version1 = (DPOW_VERSION >> 8) & 0xff;
memcpy(np->packet,data,datalen); memcpy(np->packet,data,datalen);
portable_mutex_lock(&dp->dpowmutex);
sentbytes = nn_send(myinfo->dpowsock,np,size,0); sentbytes = nn_send(myinfo->dpowsock,np,size,0);
portable_mutex_unlock(&dp->dpowmutex);
free(np); free(np);
printf("NANOSEND ht.%d channel.%08x (%d) pax.%08x datalen.%d (%d %llx)\n",np->height,np->channel,size,np->notarize.paxwdcrc,datalen,bp->bestk,(long long)bp->bestmask); printf("NANOSEND ht.%d channel.%08x (%d) pax.%08x datalen.%d (%d %llx)\n",np->height,np->channel,size,np->notarize.paxwdcrc,datalen,bp->bestk,(long long)bp->bestmask);
} }
@ -818,6 +820,7 @@ void dpow_nanomsg_update(struct supernet_info *myinfo)
int32_t i,n=0,num=0,size,firstz = -1; uint32_t crc32,r,m; struct dpow_nanomsghdr *np=0; struct dpow_info *dp; struct dpow_block *bp; struct dex_nanomsghdr *dexp = 0; int32_t i,n=0,num=0,size,firstz = -1; uint32_t crc32,r,m; struct dpow_nanomsghdr *np=0; struct dpow_info *dp; struct dpow_block *bp; struct dex_nanomsghdr *dexp = 0;
if ( time(NULL) < myinfo->nanoinit+5 ) if ( time(NULL) < myinfo->nanoinit+5 )
return; return;
portable_mutex_lock(&dp->dpowmutex);
while ( (size= nn_recv(myinfo->dpowsock,&np,NN_MSG,0)) >= 0 ) while ( (size= nn_recv(myinfo->dpowsock,&np,NN_MSG,0)) >= 0 )
{ {
num++; num++;
@ -868,6 +871,7 @@ void dpow_nanomsg_update(struct supernet_info *myinfo)
if ( size == 0 || n++ > 100 ) if ( size == 0 || n++ > 100 )
break; break;
} }
portable_mutex_unlock(&dp->dpowmutex);
if ( 0 && n != 0 ) if ( 0 && n != 0 )
printf("nanoupdates.%d\n",n); printf("nanoupdates.%d\n",n);
n = 0; n = 0;

20
iguana/dpow/dpow_rpc.c

@ -617,7 +617,7 @@ cJSON *dpow_paxjson(struct pax_transaction *pax)
uint64_t dpow_paxtotal(struct dpow_info *dp) uint64_t dpow_paxtotal(struct dpow_info *dp)
{ {
struct pax_transaction *pax,*tmp; uint64_t total = 0; struct pax_transaction *pax,*tmp; uint64_t total = 0;
pthread_mutex_lock(&dp->mutex); pthread_mutex_lock(&dp->paxmutex);
/*if ( dp->PAX != 0 ) /*if ( dp->PAX != 0 )
{ {
tmp = 0; tmp = 0;
@ -635,25 +635,25 @@ uint64_t dpow_paxtotal(struct dpow_info *dp)
if ( pax->marked == 0 ) if ( pax->marked == 0 )
total += pax->komodoshis; total += pax->komodoshis;
} }
pthread_mutex_unlock(&dp->mutex); pthread_mutex_unlock(&dp->paxmutex);
return(total); return(total);
} }
struct pax_transaction *dpow_paxfind(struct dpow_info *dp,struct pax_transaction *space,bits256 txid,uint16_t vout) struct pax_transaction *dpow_paxfind(struct dpow_info *dp,struct pax_transaction *space,bits256 txid,uint16_t vout)
{ {
struct pax_transaction *pax; struct pax_transaction *pax;
pthread_mutex_lock(&dp->mutex); pthread_mutex_lock(&dp->paxmutex);
HASH_FIND(hh,dp->PAX,&txid,sizeof(txid),pax); HASH_FIND(hh,dp->PAX,&txid,sizeof(txid),pax);
if ( pax != 0 ) if ( pax != 0 )
memcpy(space,pax,sizeof(*pax)); memcpy(space,pax,sizeof(*pax));
pthread_mutex_unlock(&dp->mutex); pthread_mutex_unlock(&dp->paxmutex);
return(pax); return(pax);
} }
struct pax_transaction *dpow_paxmark(struct dpow_info *dp,struct pax_transaction *space,bits256 txid,uint16_t vout,int32_t mark) struct pax_transaction *dpow_paxmark(struct dpow_info *dp,struct pax_transaction *space,bits256 txid,uint16_t vout,int32_t mark)
{ {
struct pax_transaction *pax; struct pax_transaction *pax;
pthread_mutex_lock(&dp->mutex); pthread_mutex_lock(&dp->paxmutex);
HASH_FIND(hh,dp->PAX,&txid,sizeof(txid),pax); HASH_FIND(hh,dp->PAX,&txid,sizeof(txid),pax);
if ( pax == 0 ) if ( pax == 0 )
{ {
@ -670,14 +670,14 @@ struct pax_transaction *dpow_paxmark(struct dpow_info *dp,struct pax_transaction
printf(" paxmark.ht %d vout%d\n",mark,vout); printf(" paxmark.ht %d vout%d\n",mark,vout);
memcpy(space,pax,sizeof(*pax)); memcpy(space,pax,sizeof(*pax));
} }
pthread_mutex_unlock(&dp->mutex); pthread_mutex_unlock(&dp->paxmutex);
return(pax); return(pax);
} }
cJSON *dpow_withdraws_pending(struct dpow_info *dp) cJSON *dpow_withdraws_pending(struct dpow_info *dp)
{ {
struct pax_transaction *pax,*tmp; cJSON *retjson = cJSON_CreateArray(); struct pax_transaction *pax,*tmp; cJSON *retjson = cJSON_CreateArray();
pthread_mutex_lock(&dp->mutex); pthread_mutex_lock(&dp->paxmutex);
/*if ( dp->PAX != 0 ) /*if ( dp->PAX != 0 )
{ {
tmp = 0; tmp = 0;
@ -695,14 +695,14 @@ cJSON *dpow_withdraws_pending(struct dpow_info *dp)
if ( pax->marked == 0 ) if ( pax->marked == 0 )
jaddi(retjson,dpow_paxjson(pax)); jaddi(retjson,dpow_paxjson(pax));
} }
pthread_mutex_unlock(&dp->mutex); pthread_mutex_unlock(&dp->paxmutex);
return(retjson); return(retjson);
} }
void dpow_issuer_withdraw(struct dpow_info *dp,char *coinaddr,uint64_t fiatoshis,int32_t shortflag,char *symbol,uint64_t komodoshis,uint8_t *rmd160,bits256 txid,uint16_t vout,int32_t kmdheight,int32_t height) // assetchain context void dpow_issuer_withdraw(struct dpow_info *dp,char *coinaddr,uint64_t fiatoshis,int32_t shortflag,char *symbol,uint64_t komodoshis,uint8_t *rmd160,bits256 txid,uint16_t vout,int32_t kmdheight,int32_t height) // assetchain context
{ {
struct pax_transaction *pax; struct pax_transaction *pax;
pthread_mutex_lock(&dp->mutex); pthread_mutex_lock(&dp->paxmutex);
HASH_FIND(hh,dp->PAX,&txid,sizeof(txid),pax); HASH_FIND(hh,dp->PAX,&txid,sizeof(txid),pax);
if ( pax == 0 ) if ( pax == 0 )
{ {
@ -711,7 +711,7 @@ void dpow_issuer_withdraw(struct dpow_info *dp,char *coinaddr,uint64_t fiatoshis
pax->vout = vout; pax->vout = vout;
HASH_ADD_KEYPTR(hh,dp->PAX,&pax->txid,sizeof(pax->txid),pax); HASH_ADD_KEYPTR(hh,dp->PAX,&pax->txid,sizeof(pax->txid),pax);
} }
pthread_mutex_unlock(&dp->mutex); pthread_mutex_unlock(&dp->paxmutex);
if ( coinaddr != 0 ) if ( coinaddr != 0 )
{ {
strcpy(pax->coinaddr,coinaddr); strcpy(pax->coinaddr,coinaddr);

6
iguana/iguana_notary.c

@ -298,7 +298,11 @@ TWO_STRINGS(iguana,dpow,symbol,pubkey)
dp->blocks = calloc(dp->maxblocks,sizeof(*dp->blocks)); dp->blocks = calloc(dp->maxblocks,sizeof(*dp->blocks));
} }
if ( myinfo->numdpows++ == 0 ) if ( myinfo->numdpows++ == 0 )
portable_mutex_init(&dp->mutex); {
portable_mutex_init(&dp->paxmutex);
portable_mutex_init(&dp->dexmutex);
portable_mutex_init(&dp->dpowmutex);
}
PAX_init(); PAX_init();
//printf(">>>>>>>>>>>>>>> call paxpending\n"); //printf(">>>>>>>>>>>>>>> call paxpending\n");
//uint8_t buf[32768]; //uint8_t buf[32768];

Loading…
Cancel
Save