jl777 8 years ago
parent
commit
62f7ef38f0
  1. 11
      iguana/dPoW.h
  2. 27
      iguana/dpow/dpow_rpc.c

11
iguana/dPoW.h

@ -106,6 +106,16 @@ struct dpow_block
char signedtx[32768];//,rawtx[32768];
};
struct pax_transaction
{
UT_hash_handle hh;
bits256 txid;
uint64_t komodoshis,fiatoshis;
int32_t marked,height;
uint16_t vout;
char symbol[16],coinaddr[64]; uint8_t rmd160[20],shortflag;
};
struct dpow_info
{
char symbol[16],dest[16]; uint8_t minerkey33[33],minerid; uint64_t lastrecvmask;
@ -114,6 +124,7 @@ struct dpow_info
bits256 srctx[DPOW_MAXTX],desttx[DPOW_MAXTX];
uint32_t KMDREALTIME,destupdated,srcconfirms,numdesttx,numsrctx,lastsplit,cancelratify,crcs[16];
int32_t maxblocks,KMDHEIGHT,SHORTFLAG;
struct pax_transaction *PAX;
portable_mutex_t mutex;
struct dpow_block **blocks;
};

27
iguana/dpow/dpow_rpc.c

@ -451,16 +451,6 @@ int32_t dpow_scriptitemlen(int32_t *opretlenp,uint8_t *script)
return(len);
}
struct pax_transaction
{
UT_hash_handle hh;
bits256 txid;
uint64_t komodoshis,fiatoshis;
int32_t marked,height;
uint16_t vout;
char symbol[16],coinaddr[64]; uint8_t rmd160[20],shortflag;
} *PAX;
cJSON *dpow_paxjson(struct pax_transaction *pax)
{
cJSON *item = cJSON_CreateObject();
@ -478,10 +468,11 @@ cJSON *dpow_paxjson(struct pax_transaction *pax)
}
return(item);
}
uint64_t dpow_paxtotal()
uint64_t dpow_paxtotal(struct dpow_info *dp)
{
struct pax_transaction *pax,*tmp; uint64_t total = 0;
HASH_ITER(hh,PAX,pax,tmp)
HASH_ITER(hh,dp->PAX,pax,tmp)
{
if ( pax->marked == 0 )
total += pax->fiatoshis;
@ -493,7 +484,7 @@ struct pax_transaction *dpow_paxfind(struct dpow_info *dp,struct pax_transaction
{
struct pax_transaction *pax;
pthread_mutex_lock(&dp->mutex);
HASH_FIND(hh,PAX,&txid,sizeof(txid),pax);
HASH_FIND(hh,dp->PAX,&txid,sizeof(txid),pax);
if ( pax != 0 )
memcpy(space,pax,sizeof(*pax));
pthread_mutex_unlock(&dp->mutex);
@ -504,13 +495,13 @@ struct pax_transaction *dpow_paxmark(struct dpow_info *dp,struct pax_transaction
{
struct pax_transaction *pax;
pthread_mutex_lock(&dp->mutex);
HASH_FIND(hh,PAX,&txid,sizeof(txid),pax);
HASH_FIND(hh,dp->PAX,&txid,sizeof(txid),pax);
if ( pax == 0 )
{
pax = (struct pax_transaction *)calloc(1,sizeof(*pax));
pax->txid = txid;
pax->vout = vout;
HASH_ADD_KEYPTR(hh,PAX,&pax->txid,sizeof(pax->txid),pax);
HASH_ADD_KEYPTR(hh,dp->PAX,&pax->txid,sizeof(pax->txid),pax);
}
if ( pax != 0 )
{
@ -528,7 +519,7 @@ cJSON *dpow_withdraws_pending(struct dpow_info *dp)
{
struct pax_transaction *pax,*tmp; cJSON *retjson = cJSON_CreateArray();
pthread_mutex_lock(&dp->mutex);
HASH_ITER(hh,PAX,pax,tmp);
HASH_ITER(hh,dp->PAX,pax,tmp);
{
printf("iter pax.%p\n",pax);
if ( pax != 0 && pax->marked == 0 )
@ -543,7 +534,7 @@ void dpow_issuer_withdraw(struct dpow_info *dp,char *coinaddr,uint64_t fiatoshis
{
struct pax_transaction *pax; int32_t addflag = 0;
pthread_mutex_lock(&dp->mutex);
HASH_FIND(hh,PAX,&txid,sizeof(txid),pax);
HASH_FIND(hh,dp->PAX,&txid,sizeof(txid),pax);
if ( pax == 0 )
{
pax = (struct pax_transaction *)calloc(1,sizeof(*pax));
@ -572,7 +563,7 @@ void dpow_issuer_withdraw(struct dpow_info *dp,char *coinaddr,uint64_t fiatoshis
if ( addflag != 0 )
{
printf("addflag\n");
HASH_ADD_KEYPTR(hh,PAX,&pax->txid,sizeof(pax->txid),pax);
HASH_ADD_KEYPTR(hh,dp->PAX,&pax->txid,sizeof(pax->txid),pax);
}
pthread_mutex_unlock(&dp->mutex);
}

Loading…
Cancel
Save