Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
eda52d766a
  1. 22
      deprecated/obsolete.h
  2. 4
      iguana/iguana777.h
  3. 13
      iguana/iguana_msg.c
  4. 56
      iguana/iguana_ramchain.c
  5. 1
      iguana/iguana_rpc.c
  6. 2
      iguana/iguana_tx.c
  7. 4
      iguana/main.c

22
deprecated/obsolete.h

@ -16195,6 +16195,28 @@ len = 0;
getchar();
}
}
int32_t i,numretries = 5;
for (i=0; i<numretries; i++)
{
err = fwrite(srcptr,1,len,fp);
/*err = len;
for (j=0; j<len; j++)
if ( fputc(((uint8_t *)srcptr)[j],fp) < 0 )
{
err = -1;
break;
}*/
if ( err == len )
{
fflush(fp);
//if ( i > 2 )
//printf("write.%d of %d worked!\n",i+1,numretries+1);
break;
}
fseek(fp,startfpos,SEEK_SET);
}
}
#else
#endif
#endif

4
iguana/iguana777.h

@ -26,7 +26,11 @@ typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t
#define IGUANA_SERIALIZE_SPENDVECTORGEN
//#define IGUANA_DISABLEPEERS
#define _IGUANA_MAXSTUCKTIME 10
#ifdef __PNACL__
#define IGUANA_MAXITERATIONS 77
#else
#define IGUANA_MAXITERATIONS 10000
#endif
#define IGUANA_DEFAULTLAG 30
#define IGUANA_MAXCOINS 64

13
iguana/iguana_msg.c

@ -570,11 +570,11 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
else
{
addr->msgcounts.getblocks++;
len = iguana_rwnum(0,&serialized[sizeof(struct iguana_msghdr)],sizeof(uint32_t),&tmp);
len += iguana_rwvarint32(0,&serialized[sizeof(struct iguana_msghdr) + len],(uint32_t *)&n);
len = iguana_rwnum(0,&data[sizeof(struct iguana_msghdr)],sizeof(uint32_t),&tmp);
len += iguana_rwvarint32(0,&data[sizeof(struct iguana_msghdr) + len],(uint32_t *)&n);
for (i=0; i<n; i++)
{
len += iguana_rwbignum(0,&serialized[sizeof(struct iguana_msghdr) + len],sizeof(bits256),hash2.bytes);
len += iguana_rwbignum(0,&data[sizeof(struct iguana_msghdr) + len],sizeof(bits256),hash2.bytes);
iguana_peerblockrequest(coin,addr->blockspace,sizeof(addr->blockspace),addr,hash2,0);
if ( bits256_nonz(hash2) == 0 )
break;
@ -626,11 +626,11 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
else
{
addr->msgcounts.getheaders++;
len = iguana_rwnum(0,&serialized[sizeof(struct iguana_msghdr)],sizeof(uint32_t),&tmp);
len += iguana_rwvarint32(0,&serialized[sizeof(struct iguana_msghdr) + len],(uint32_t *)&n);
len = iguana_rwnum(0,&data[sizeof(struct iguana_msghdr)],sizeof(uint32_t),&tmp);
len += iguana_rwvarint32(0,&data[sizeof(struct iguana_msghdr) + len],(uint32_t *)&n);
for (i=nonz=0; i<n; i++)
{
len += iguana_rwbignum(0,&serialized[sizeof(struct iguana_msghdr) + len],sizeof(bits256),hash2.bytes);
len += iguana_rwbignum(0,&data[sizeof(struct iguana_msghdr) + len],sizeof(bits256),hash2.bytes);
if ( bits256_nonz(hash2) == 0 )
break;
else if ( iguana_peerhdrrequest(coin,addr,hash2) > 0 )
@ -705,6 +705,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
}
else
{
len = 0;
if ( (sendlen= iguana_peeraddrrequest(coin,addr,addr->blockspace,sizeof(addr->blockspace))) > 0 )
retval = iguana_queue_send(coin,addr,0,addr->blockspace,"addr",sendlen,0,0);
addr->msgcounts.getaddr++;

56
iguana/iguana_ramchain.c

@ -108,26 +108,27 @@ int32_t iguana_peerfname(struct iguana_info *coin,int32_t *hdrsip,char *dirname,
else bundlei++;
}
hash2 = bp->hashes[0], *hdrsip = bp->hdrsi;
subdir = bp->bundleheight / IGUANA_SUBDIRDIVISOR;
if ( numblocks == 1 )
{
sprintf(fname,"%s/%s/%d",dirname,coin->symbol,subdir), OS_ensure_directory(fname);
sprintf(fname,"%s/%s/%d/%d",dirname,coin->symbol,subdir,bp->bundleheight), OS_ensure_directory(fname);
if ( bits256_nonz(bp->hashes[bundlei]) != 0 )
sprintf(fname,"%s/%s/%d/%s_%u.%d",dirname,coin->symbol,bp->bundleheight,bits256_str(str,bp->hashes[bundlei]),ipbits>1?ipbits:*hdrsip,bundlei);
sprintf(fname,"%s/%s/%d/%d/%s_%u.%d",dirname,coin->symbol,subdir,bp->bundleheight,bits256_str(str,bp->hashes[bundlei]),ipbits>1?ipbits:*hdrsip,bundlei);
else
{
printf("no hash for [%d:%d]\n",bp->hdrsi,bundlei);
return(-3);
}
}
else if ( strncmp(GLOBAL_DBDIR,dirname,strlen(GLOBAL_DBDIR)) == 0 )
else //if ( strncmp(GLOBAL_DBDIR,dirname,strlen(GLOBAL_DBDIR)) == 0 )
{
subdir = bp->bundleheight / IGUANA_SUBDIRDIVISOR;
sprintf(fname,"%s/%s/%d",dirname,coin->symbol,subdir), OS_ensure_directory(fname);
sprintf(fname,"%s/%s/%d/%s_%d.%u",dirname,coin->symbol,subdir,bits256_str(str,hash2),numblocks,ipbits>1?ipbits:*hdrsip);
//#ifndef __PNACL__
// sprintf(fname,"%s/%s/%s_%d.%u",dirname,coin->symbol,bits256_str(str,hash2),numblocks,ipbits>1?ipbits:*hdrsip);
//#endif
}
else sprintf(fname,"%s/%s.%u",dirname,bits256_str(str,hash2),bp->bundleheight);
} //else sprintf(fname,"%s/%s.%u",dirname,bits256_str(str,hash2),bp->bundleheight);
OS_compatible_path(fname);
return(bundlei);
}
@ -314,6 +315,10 @@ uint32_t iguana_ramchain_addunspent20(struct iguana_info *coin,struct iguana_pee
{
if ( addr != 0 && addr->voutsfp != 0 )
{
#ifdef __PNACL__
static portable_mutex_t mutex;
portable_mutex_lock(&mutex);
#endif
u->fileid = (uint32_t)addr->addrind;
scriptpos = ftell(addr->voutsfp);
if ( (u->scriptpos= (uint32_t)scriptpos) == 0 )
@ -321,6 +326,9 @@ uint32_t iguana_ramchain_addunspent20(struct iguana_info *coin,struct iguana_pee
if ( u->scriptpos != scriptpos || fwrite(script,1,scriptlen,addr->voutsfp) != scriptlen )
printf("error writing vout scriptlen.%d errno.%d or scriptpos.%lld != %u\n",scriptlen,errno,(long long)scriptpos,u->scriptpos);
else addr->dirty[0]++;
#ifdef __PNACL__
portable_mutex_unlock(&mutex);
#endif
} else printf("addr.%p unspent error fp.%p\n",addr,addr!=0?addr->voutsfp:0);
}
}
@ -555,12 +563,19 @@ uint32_t iguana_ramchain_addspend256(struct iguana_info *coin,struct iguana_peer
s->spendind = spendind;
if ( (s->vinscriptlen= vinscriptlen) > 0 && vinscript != 0 && addr != 0 && addr->vinsfp != 0 && vinscriptlen < IGUANA_MAXSCRIPTSIZE)
{
#ifdef __PNACL__
static portable_mutex_t mutex;
portable_mutex_lock(&mutex);
#endif
s->fileid = (uint32_t)addr->addrind;
if ( (s->scriptpos= ftell(addr->vinsfp)) == 0 )
fputc(0,addr->vinsfp), s->scriptpos++;
if ( (err= (int32_t)fwrite(vinscript,1,vinscriptlen,addr->vinsfp)) != vinscriptlen )
printf("error.%d writing vinscriptlen.%d errno.%d addrind.%d\n",err,vinscriptlen,errno,addr->addrind);
else addr->dirty[1]++;
#ifdef __PNACL__
portable_mutex_unlock(&mutex);
#endif
} else s->scriptpos = 0;
//else printf("spend256 scriptfpos.%d\n",s->scriptfpos);
//char str[65]; printf("W.%p s.%d vout.%d/%d [%d] %s fpos.%u slen.%d\n",s,spendind,s->prevout,prev_vout,bp->hdrsi,bits256_str(str,prev_hash),s->scriptfpos,s->vinscriptlen);
@ -636,33 +651,14 @@ void *iguana_ramchain_offset(char *fname,void *dest,uint8_t *lhash,FILE *fp,uint
}
else if ( fp != 0 && len > 0 )
{
startfpos = ftell(fp);
#ifdef __PNACL__
if ( 1 )
{
int32_t i,numretries = 5;
for (i=0; i<numretries; i++)
{
err = fwrite(srcptr,1,len,fp);
/*err = len;
for (j=0; j<len; j++)
if ( fputc(((uint8_t *)srcptr)[j],fp) < 0 )
{
err = -1;
break;
}*/
if ( err == len )
{
fflush(fp);
//if ( i > 2 )
//printf("write.%d of %d worked!\n",i+1,numretries+1);
break;
}
fseek(fp,startfpos,SEEK_SET);
}
}
#else
static portable_mutex_t mutex;
portable_mutex_lock(&mutex);
#endif
startfpos = ftell(fp);
err = fwrite(srcptr,1,len,fp);
#ifdef __PNACL__
portable_mutex_unlock(&mutex);
#endif
if ( err != len )
{

1
iguana/iguana_rpc.c

@ -1001,6 +1001,7 @@ void iguana_rpcloop(void *args)
struct sockaddr_in cli_addr; uint32_t ipbits,i,size = IGUANA_WIDTH*IGUANA_HEIGHT*16 + 512;
if ( (port= myinfo->argport) == 0 )
port = myinfo->rpcport;
else myinfo->argport = 0;
if ( jsonbuf == 0 )
jsonbuf = calloc(1,IGUANA_MAXPACKETSIZE);
while ( (bindsock= iguana_socket(1,"127.0.0.1",port)) < 0 )

2
iguana/iguana_tx.c

@ -249,7 +249,7 @@ int32_t iguana_peerblockrequest(struct iguana_info *coin,uint8_t *blockspace,int
}
} else printf("iguana_peerblockrequest: error merkle cmp tx.[%d] for ht.%d\n",i,bp->bundleheight+bundlei);
} else printf("iguana_peerblockrequest: error merkle verify tx.[%d] for ht.%d\n",i,bp->bundleheight+bundlei);
} else printf("iguana_peerblockrequest: error getting tx.[%d] for ht.%d block.%p main.%d ht.%d\n",i,bp->bundleheight+bundlei,block,block!=0?block->mainchain:-1,block!=0?block->height:-1);
} //else printf("iguana_peerblockrequest: error getting tx.[%d] for ht.%d block.%p main.%d ht.%d\n",i,bp->bundleheight+bundlei,block,block!=0?block->mainchain:-1,block!=0?block->height:-1);
}
else
{

4
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";
@ -1142,7 +1142,7 @@ void iguana_appletests(struct supernet_info *myinfo)
exit(-1);
}
sleep(1);*/
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"prefetchlag\":13,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":500,\"endpend\":500,\"services\":128,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0,myinfo->rpcport)) != 0 )
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"prefetchlag\":13,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":500,\"endpend\":500,\"services\":129,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0,myinfo->rpcport)) != 0 )
{
free(str);
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":1024,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1}"),0,myinfo->rpcport)) != 0 )

Loading…
Cancel
Save