Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
dc98da963e
  1. 17
      iguana/iguana_ramchain.c
  2. 6
      iguana/iguana_tx.c
  3. 12
      iguana/iguana_unspents.c
  4. 2
      iguana/main.c

17
iguana/iguana_ramchain.c

@ -628,12 +628,11 @@ void *iguana_ramchain_offset(char *fname,void *dest,uint8_t *lhash,FILE *fp,uint
{
startfpos = ftell(fp);
#ifdef __PNACL__
if ( 0 )
if ( 1 )
{
int32_t i,numretries = 5;
for (i=0; i<numretries; i++)
{
fseek(fp,startfpos,SEEK_SET);
err = fwrite(srcptr,1,len,fp);
/*err = len;
for (j=0; j<len; j++)
@ -649,9 +648,9 @@ void *iguana_ramchain_offset(char *fname,void *dest,uint8_t *lhash,FILE *fp,uint
//printf("write.%d of %d worked!\n",i+1,numretries+1);
break;
}
fseek(fp,startfpos,SEEK_SET);
}
}
err = fwrite(srcptr,1,len,fp);
#else
err = fwrite(srcptr,1,len,fp);
#endif
@ -1042,8 +1041,8 @@ long iguana_ramchain_save(struct iguana_info *coin,RAMCHAIN_FUNC,uint32_t ipbits
}
}*/
#ifdef __PNACL__
//static portable_mutex_t mutex;
//portable_mutex_lock(&mutex);
static portable_mutex_t mutex;
portable_mutex_lock(&mutex);
#endif
if ( (fp= fopen(fname,"wb")) == 0 )
printf("iguana_ramchain_save: couldnt create.(%s) errno.%d\n",fname,errno);
@ -1066,7 +1065,7 @@ long iguana_ramchain_save(struct iguana_info *coin,RAMCHAIN_FUNC,uint32_t ipbits
fclose(fp);
}
#ifdef __PNACL__
//portable_mutex_unlock(&mutex);
portable_mutex_unlock(&mutex);
#endif
return(fpos);
}
@ -1488,12 +1487,12 @@ struct iguana_ramchain *iguana_ramchain_map(struct iguana_info *coin,char *fname
{
struct iguana_ramchain *retptr;
#ifdef __PNACL__
//static portable_mutex_t mutex;
//portable_mutex_lock(&mutex);
static portable_mutex_t mutex;
portable_mutex_lock(&mutex);
#endif
retptr = _iguana_ramchain_map(coin,fname,bp,numblocks,ramchain,hashmem,ipbits,hash2,prevhash2,bundlei,fpos,allocextras,expanded);
#ifdef __PNACL__
//portable_mutex_unlock(&mutex);
portable_mutex_unlock(&mutex);
#endif
return(retptr);
}

6
iguana/iguana_tx.c

@ -183,9 +183,9 @@ int32_t iguana_ramtxbytes(struct iguana_info *coin,uint8_t *serialized,int32_t m
*txidp = bits256_doublesha256(txidstr,serialized,len);
if ( memcmp(txidp,tx->txid.bytes,sizeof(*txidp)) != 0 )
{
for (i=0; i<len; i++)
printf("%02x",serialized[i]);
char str[65],str2[65]; printf("\nrw.%d numvins.%d numvouts.%d error generating txbytes txid %s vs %s\n",rwflag,numvins,numvouts,bits256_str(str,*txidp),bits256_str(str2,tx->txid));
//for (i=0; i<len; i++)
// printf("%02x",serialized[i]);
//char str[65],str2[65]; printf("\nrw.%d numvins.%d numvouts.%d error generating txbytes txid %s vs %s\n",rwflag,numvins,numvouts,bits256_str(str,*txidp),bits256_str(str2,tx->txid));
return(-1);
}
return(len);

12
iguana/iguana_unspents.c

@ -829,7 +829,7 @@ char *iguana_bundleaddrs(struct iguana_info *coin,int32_t hdrsi)
int64_t iguana_pkhashbalance(struct iguana_info *coin,cJSON *array,int64_t *spentp,int32_t *nump,struct iguana_ramchain *ramchain,struct iguana_pkhash *p,uint32_t lastunspentind,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t hdrsi,int32_t height)
{
struct iguana_unspent *U; int32_t spentheight; uint32_t unspentind; int64_t balance = 0; struct iguana_txid *T; struct iguana_ramchaindata *rdata = 0;
struct iguana_unspent *U; int32_t spentheight; uint32_t pkind=0,unspentind; int64_t spent = 0, balance = 0; struct iguana_txid *T; struct iguana_account *A2; struct iguana_ramchaindata *rdata = 0;
*spentp = *nump = 0;
if ( 0 && ramchain == &coin->RTramchain && coin->RTramchain_busy != 0 )
{
@ -853,9 +853,17 @@ int64_t iguana_pkhashbalance(struct iguana_info *coin,cJSON *array,int64_t *spen
balance += U[unspentind].value;
if ( array != 0 )
jaddi(array,iguana_unspentjson(coin,hdrsi,unspentind,T,&U[unspentind],rmd160,coinaddr,pubkey33));
} else (*spentp) += U[unspentind].value;
} else spent += U[unspentind].value;
if ( p->pkind != U[unspentind].pkind )
printf("warning: [%d] p->pkind.%u vs U->pkind.%u for u%d\n",hdrsi,p->pkind,U[unspentind].pkind,unspentind);
unspentind = U[unspentind].prevunspentind;
}
if ( (A2= ramchain->A) != 0 )
{
printf("[%d] spent %.8f (%.8f) vs A2[%u] %.8f\n",hdrsi,dstr(spent),dstr(*spentp),pkind,dstr(A2[pkind].total));
}
(*spentp) += spent;
balance -= spent;
return(balance);
}

2
iguana/main.c

@ -68,7 +68,7 @@ int32_t HDRnet,netBLOCKS;
cJSON *API_json;
#ifdef __PNACL__
char GLOBAL_TMPDIR[512] = "/tmp";
char GLOBAL_TMPDIR[512] = "/DB/tmp";
char GLOBAL_DBDIR[512] = "/DB";
char GLOBAL_HELPDIR[512] = "/DB/help";
char GLOBAL_VALIDATEDIR[512] = "/DB/purgeable";

Loading…
Cancel
Save