You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

520 lines
22 KiB

9 years ago
/******************************************************************************
9 years ago
* Copyright © 2014-2016 The SuperNET Developers. *
9 years ago
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* SuperNET software, including this file may be copied, modified, propagated *
* or distributed except according to the terms contained in the LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#include "iguana777.h"
void iguana_initQ(queue_t *Q,char *name)
{
char *tst,*str = "need to init each Q when single threaded";
9 years ago
memset(Q,0,sizeof(*Q));
strcpy(Q->name,name);
9 years ago
queue_enqueue(name,Q,queueitem(str),1);
if ( (tst= queue_dequeue(Q,1)) != 0 )
free_queueitem(tst);
}
void iguana_initQs(struct iguana_info *coin)
{
int32_t i;
9 years ago
iguana_initQ(&coin->acceptQ,"acceptQ");
9 years ago
iguana_initQ(&coin->hdrsQ,"hdrsQ");
iguana_initQ(&coin->blocksQ,"blocksQ");
iguana_initQ(&coin->priorityQ,"priorityQ");
iguana_initQ(&coin->possibleQ,"possibleQ");
iguana_initQ(&coin->cacheQ,"cacheQ");
9 years ago
iguana_initQ(&coin->recvQ,"recvQ");
9 years ago
for (i=0; i<IGUANA_MAXPEERS; i++)
iguana_initQ(&coin->peers.active[i].sendQ,"addrsendQ");
}
9 years ago
void iguana_initpeer(struct iguana_info *coin,struct iguana_peer *addr,uint64_t ipbits)
9 years ago
{
memset(addr,0,sizeof(*addr));
addr->ipbits = ipbits;
addr->usock = -1;
9 years ago
expand_ipbits(addr->ipaddr,(uint32_t)addr->ipbits);
9 years ago
//addr->pending = (uint32_t)time(NULL);
strcpy(addr->symbol,coin->symbol);
strcpy(addr->coinstr,coin->name);
iguana_initQ(&addr->sendQ,"addrsendQ");
}
9 years ago
void iguana_initcoin(struct iguana_info *coin,cJSON *argjson)
9 years ago
{
9 years ago
int32_t i; char dirname[1024],*prefix = "";
#ifdef __PNACL__
prefix = "";
#endif
sprintf(dirname,"%s%s/%s",prefix,GLOBALTMPDIR,coin->symbol), OS_portable_path(dirname);
sprintf(dirname,"%stmp/%s",prefix,coin->symbol), OS_portable_path(dirname);
9 years ago
portable_mutex_init(&coin->peers_mutex);
portable_mutex_init(&coin->blocks_mutex);
iguana_meminit(&coin->blockMEM,"blockMEM",coin->blockspace,sizeof(coin->blockspace),0);
iguana_initQs(coin);
9 years ago
coin->bindsock = -1;
9 years ago
OS_randombytes((unsigned char *)&coin->instance_nonce,sizeof(coin->instance_nonce));
coin->startutc = (uint32_t)time(NULL);
while ( time(NULL) == coin->startutc )
usleep(1);
9 years ago
coin->startutc++;
printf("start.%u\n",coin->startutc);
9 years ago
coin->startmillis = OS_milliseconds(), coin->starttime = tai_now(coin->startmillis);
coin->avetime = 1 * 100;
//coin->R.maxrecvbundles = IGUANA_INITIALBUNDLES;
for (i=0; i<IGUANA_MAXPEERS; i++)
coin->peers.active[i].usock = -1;
}
bits256 iguana_genesis(struct iguana_info *coin,struct iguana_chain *chain)
{
9 years ago
struct iguana_block block,*ptr; struct iguana_msgblock msg; bits256 hash2; char str[65],str2[65]; uint8_t buf[1024]; int32_t height;
if ( chain->genesis_hex == 0 )
{
printf("no genesis_hex for %s\n",coin->symbol);
memset(hash2.bytes,0,sizeof(hash2));
return(hash2);
}
9 years ago
decode_hex(buf,(int32_t)strlen(chain->genesis_hex)/2,(char *)chain->genesis_hex);
hash2 = bits256_doublesha256(0,buf,sizeof(struct iguana_msgblockhdr));
iguana_rwblock(0,&hash2,buf,&msg);
if ( memcmp(hash2.bytes,chain->genesis_hashdata,sizeof(hash2)) != 0 )
{
bits256_str(str,hash2);
9 years ago
printf("genesis mismatch? calculated %s vs %s\n",str,bits256_str(str2,*(bits256 *)chain->genesis_hashdata));
//hash2 = bits256_conv("00000ac7d764e7119da60d3c832b1d4458da9bc9ef9d5dd0d91a15f690a46d99");
9 years ago
//memset(hash2.bytes,0,sizeof(hash2));
//return(hash2);
9 years ago
}
bits256_str(str,hash2);
printf("genesis.(%s) len.%d hash.%s\n",chain->genesis_hex,(int32_t)sizeof(msg.H),str);
iguana_blockconv(&block,&msg,hash2,0);
9 years ago
block.RO.txn_count = 1;
9 years ago
block.RO.numvouts = 1;
iguana_gotdata(coin,0,0);
9 years ago
if ( (ptr= iguana_blockhashset("genesis0",coin,0,hash2,1)) != 0 )
9 years ago
{
iguana_blockcopy(coin,ptr,&block);
9 years ago
ptr->mainchain = 1;
ptr->height = 0;
9 years ago
coin->blocks.RO[0] = block.RO;
if ( (height= iguana_chainextend(coin,ptr)) == 0 )
{
block = *ptr;
coin->blocks.recvblocks = coin->blocks.issuedblocks = 1;
}
else printf("genesis block doesnt validate for %s ht.%d\n",coin->symbol,height);
} else printf("couldnt hashset genesis\n");
if ( coin->blocks.hwmchain.height != 0 || fabs(coin->blocks.hwmchain.PoW - block.PoW) > SMALLVAL || memcmp(coin->blocks.hwmchain.RO.hash2.bytes,hash2.bytes,sizeof(hash2)) != 0 )
{
printf("%s genesis values mismatch hwmheight.%d %.15f %.15f %s\n",coin->name,coin->blocks.hwmchain.height,coin->blocks.hwmchain.PoW,block.PoW,bits256_str(str,coin->blocks.hwmchain.RO.hash2));
getchar();
}
int32_t bundlei = -2;
9 years ago
static const bits256 zero;
9 years ago
iguana_bundlecreate(coin,&bundlei,0,hash2,zero,1);
9 years ago
_iguana_chainlink(coin,iguana_blockfind("genesis",coin,hash2));
9 years ago
return(hash2);
}
int32_t iguana_savehdrs(struct iguana_info *coin)
{
9 years ago
char fname[512],shastr[65],tmpfname[512],tmpfname2[512],str2[65],str[65],oldfname[512],*prefix="";
9 years ago
bits256 sha256all; FILE *fp,*fp2; struct iguana_bundle *bp; int32_t hdrsi,n,retval = 0;
9 years ago
n = coin->blocks.hwmchain.height + 1;
9 years ago
#ifdef __PNACL__
prefix = "";
#endif
sprintf(tmpfname,"%s%s/%s/hdrs.txt",prefix,GLOBALTMPDIR,coin->symbol), OS_compatible_path(tmpfname);
sprintf(tmpfname2,"%s%s/%s/hdrs.h",prefix,GLOBALTMPDIR,coin->symbol), OS_compatible_path(tmpfname);
sprintf(oldfname,"%sconfs/%s_oldhdrs.txt",prefix,coin->symbol), OS_compatible_path(oldfname);
sprintf(fname,"%sconfs/%s_hdrs.txt",prefix,coin->symbol), OS_compatible_path(fname);
9 years ago
if ( (fp= fopen(tmpfname,"w")) != 0 )
{
9 years ago
if ( (fp2= fopen(tmpfname2,"w")) != 0 )
fprintf(fp2,"char *%s_hdrs[][4] = {\n",coin->symbol);
9 years ago
fprintf(fp,"%d\n",n);
9 years ago
for (hdrsi=0; hdrsi<coin->bundlescount; hdrsi++)
9 years ago
{
9 years ago
if ( (bp= coin->bundles[hdrsi]) != 0 && bp->numhashes >= bp->n )
9 years ago
{
9 years ago
shastr[0] = 0;
if ( bits256_nonz(bp->allhash) == 0 )
9 years ago
{
9 years ago
vcalc_sha256(shastr,sha256all.bytes,bp->hashes[0].bytes,sizeof(*bp->hashes) * coin->chain->bundlesize);
bp->allhash = sha256all;
9 years ago
}
9 years ago
else
{
sha256all = bp->allhash;
bits256_str(shastr,bp->allhash);
}
fprintf(fp,"%d %s %s %s\n",bp->bundleheight,bits256_str(str,bp->hashes[0]),shastr,bits256_str(str2,bp->hashes[1]));
9 years ago
if ( fp2 != 0 )
fprintf(fp2,"{ \"%d\", \"%s\", \"%s\", \"%s\"},\n",bp->bundleheight,bits256_str(str,bp->hashes[0]),shastr,bits256_str(str2,bp->hashes[1]));
9 years ago
}
else
{
if ( bp != 0 && bits256_nonz(bp->hashes[0]) != 0 )
9 years ago
{
9 years ago
fprintf(fp,"%d %s\n",bp->bundleheight,bits256_str(str,bp->hashes[0]));
9 years ago
if ( fp2 != 0 )
fprintf(fp2,"{ \"%d\", \"%s\", \"%s\", \"%s\"},\n",bp->bundleheight,bits256_str(str,bp->hashes[0]),"","");
}
9 years ago
break;
}
9 years ago
}
9 years ago
//printf("compare hdrs.txt %ld vs (%s) %ld\n",ftell(fp),fname,(long)OS_filesize(fname));
9 years ago
if ( (long)ftell(fp) > OS_filesize(fname) )
9 years ago
{
printf("new hdrs.txt %ld vs (%s) %ld\n",ftell(fp),fname,(long)OS_filesize(fname));
fclose(fp);
OS_renamefile(fname,oldfname);
OS_copyfile(tmpfname,fname,1);
} else fclose(fp);
9 years ago
if ( fp2 != 0 )
{
fprintf(fp2,"};\n");
fclose(fp2);
}
9 years ago
}
9 years ago
else
{
printf("iguana_savehdrs: couldnt create.(%s)\n",tmpfname);
return(-1);
}
9 years ago
return(retval);
}
void iguana_parseline(struct iguana_info *coin,int32_t iter,FILE *fp)
{
9 years ago
int32_t j,k,m,c,height,flag,bundlei; char checkstr[1024],line[1024];
9 years ago
struct iguana_peer *addr; struct iguana_bundle *bp; bits256 allhash,hash2,hash1,zero,lastbundle;
9 years ago
struct iguana_block *block;
9 years ago
memset(&zero,0,sizeof(zero));
lastbundle = zero;
9 years ago
if ( coin->MAXPEERS > IGUANA_MAXPEERS )
coin->MAXPEERS = IGUANA_MAXPEERS;
9 years ago
if ( iter == 1 && 0 )
9 years ago
{
int32_t i; FILE *fp; char fname[512]; struct iguana_blockRO blockRO;
sprintf(fname,"blocks.%s",coin->symbol), OS_compatible_path(fname);
if ( (fp= fopen(fname,"rb")) != 0 )
{
for (i=0; i<100000000; i++)
{
if ( fread(&blockRO,1,sizeof(blockRO),fp) != sizeof(blockRO) )
break;
if ( i > (coin->blocks.maxbits - 1000) )
iguana_recvalloc(coin,i + 100000);
coin->blocks.RO[i] = blockRO;
char str[65];
if ( bits256_nonz(blockRO.hash2) > 0 )
printf("init.%d %s\n",i,bits256_str(str,blockRO.hash2));
}
fclose(fp);
printf("validate.%d blocks that were read in\n",i);
}
}
m = flag = 0;
allhash = zero;
9 years ago
memset(line,0,sizeof(line));
9 years ago
while ( fgets(line,sizeof(line),fp) > 0 )
{
j = (int32_t)strlen(line) - 1;
line[j] = 0;
//printf("parse line.(%s) maxpeers.%d\n",line,coin->MAXPEERS);
if ( iter == 0 )
{
9 years ago
if ( m < coin->MAXPEERS-3 )//&& m < 77.7 )
9 years ago
{
9 years ago
if ( 0 && m == 0 )
9 years ago
{
addr = &coin->peers.active[m++];
iguana_initpeer(coin,addr,(uint32_t)calc_ipbits("127.0.0.1"));
9 years ago
//printf("call initpeer.(%s)\n",addr->ipaddr);
9 years ago
iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD);
}
#ifndef IGUANA_DISABLEPEERS
addr = &coin->peers.active[m++];
iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(line));
9 years ago
//printf("call initpeer.(%s)\n",addr->ipaddr);
9 years ago
iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD);
#endif
}
}
else
{
for (k=height=0; k<j-1; k++)
{
if ( (c= line[k]) == ' ' )
break;
else if ( c >= '0' && c <= '9' )
height = (height * 10) + (line[k] - '0');
else break;
}
if ( line[k] == ' ' )
{
decode_hex(hash2.bytes,sizeof(hash2),line+k+1);
9 years ago
//printf("line.(%s) k.%d (%c)(%c)(%d)\n",line,k,line[k+63],line[k+64],line[k+65]);
if ( height >= 0 && bits256_nonz(hash2) != 0 )
{
if ( (bp= iguana_bundlecreate(coin,&bundlei,height,hash2,zero,0)) != 0 )
{
//printf("created bundle.%d\n",bp->hdrsi);
lastbundle = hash2;
}
}
if ( line[k + 65] != 0 && line[k+65] != '\n' && line[k+65] != '\r' )
9 years ago
{
if ( height > (coin->blocks.maxbits - 1000) )
iguana_recvalloc(coin,height + 100000);
decode_hex(allhash.bytes,sizeof(allhash),line+k+1 + 64 + 1);
init_hexbytes_noT(checkstr,allhash.bytes,sizeof(allhash));
9 years ago
//printf("parseline: k.%d %d height.%d m.%d bundlesize.%d (%s) check.(%s)\n",k,line[k],height,m,coin->chain->bundlesize,&line[k+1+65],checkstr);// + strlen(line+k+1)]);
if ( strncmp(checkstr,line+k+1 + 64 + 1,64) == 0 )
9 years ago
{
init_hexbytes_noT(checkstr,hash2.bytes,sizeof(hash2));
9 years ago
if ( strlen(line+k+1 + 2*64 + 2) == sizeof(hash1)*2 )
decode_hex(hash1.bytes,sizeof(hash1),line+k+1 + 2*64 + 2);
else memset(hash1.bytes,0,sizeof(hash1));
//char str[65],str2[65]; printf(">>>> bundle.%d got (%s)/(%s) allhash.(%s)\n",height,bits256_str(str,hash1),checkstr,bits256_str(str2,allhash));
9 years ago
if ( (bp= iguana_bundlecreate(coin,&bundlei,height,hash2,allhash,0)) != 0 )
{
9 years ago
if ( bits256_cmp(allhash,bp->allhash) != 0 )
{
printf("mismatched allhash.[%d]\n",bp->hdrsi);
bp->allhash = allhash;
}
9 years ago
bp->bundleheight = height;
9 years ago
if ( bits256_nonz(hash1) != 0 )
{
if ( (block= iguana_blockhashset("inithash1",coin,height+1,hash1,1)) != 0 )
{
iguana_bundlehashadd(coin,bp,1,block);
block->mainchain = 1;
}
}
9 years ago
if ( height == 0 && coin->current == 0 )
coin->current = coin->bundles[0] = bp;
9 years ago
lastbundle = hash2;
9 years ago
if ( (block= iguana_blockfind("parse",coin,hash2)) != 0 )
9 years ago
block->mainchain = 1, block->height = height;
9 years ago
bp->emitfinish = (uint32_t)time(NULL) + 1;
9 years ago
if ( iguana_bundleload(coin,&bp->ramchain,bp,2) != 0 )
9 years ago
{
9 years ago
if ( coin->current != 0 && coin->current->hdrsi+1 == bp->hdrsi )
coin->current = bp;
9 years ago
}
else
{
char str[65];
init_hexbytes_noT(str,hash2.bytes,sizeof(hash2));
bp->emitfinish = 0;
9 years ago
iguana_blockQ("init",coin,bp,0,hash2,1);
9 years ago
//printf("init reqhdrs.%d\n",bp->bundleheight);
9 years ago
queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(str),1);
}
}
}
}
}
}
9 years ago
memset(line,0,sizeof(line));
9 years ago
}
if ( iter == 1 )
9 years ago
iguana_initfinal(coin,lastbundle);
9 years ago
}
9 years ago
void iguana_ramchainpurge(struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_ramchain *ramchain)
{
9 years ago
iguana_ramchain_free(coin,ramchain,1);
9 years ago
}
void iguana_bundlepurge(struct iguana_info *coin,struct iguana_bundle *bp)
{
9 years ago
int32_t i; static const bits256 zero;
9 years ago
iguana_ramchainpurge(coin,bp,&bp->ramchain);
9 years ago
if ( bp->speculative != 0 )
9 years ago
{
for (i=0; i<bp->n; i++)
if ( bp->speculativecache[i] != 0 )
{
myfree(bp->speculativecache[i],*(int32_t *)bp->speculativecache[i]);
bp->speculativecache[i] = 0;
}
9 years ago
myfree(bp->speculative,sizeof(*bp->speculative) * bp->numspec);
9 years ago
}
9 years ago
bp->numspec = 0;
bp->speculative = 0;
memset(bp->hashes,0,sizeof(bp->hashes));
memset(bp->issued,0,sizeof(bp->issued));
bp->prevbundlehash2 = bp->nextbundlehash2 = bp->allhash = zero;
}
void iguana_blockpurge(struct iguana_info *coin,struct iguana_block *block)
{
if ( block->req != 0 )
{
printf("purge req inside block\n");
myfree(block->req,block->req->allocsize);
}
free(block);
}
void iguana_blockspurge(struct iguana_info *coin)
{
struct iguana_block *block,*tmp;
9 years ago
if ( 1 && coin->blocks.hash != 0 )
9 years ago
{
HASH_ITER(hh,coin->blocks.hash,block,tmp)
{
HASH_DEL(coin->blocks.hash,block);
iguana_blockpurge(coin,block);
}
coin->blocks.hash = 0;
}
if ( coin->blocks.RO != 0 )
{
myfree(coin->blocks.RO,coin->blocks.maxbits * sizeof(*coin->blocks.RO));
coin->blocks.RO = 0;
}
coin->blocks.maxbits = coin->blocks.maxblocks = coin->blocks.initblocks = coin->blocks.hashblocks = coin->blocks.issuedblocks = coin->blocks.recvblocks = coin->blocks.emitblocks = coin->blocks.parsedblocks = coin->blocks.dirty = 0;
memset(&coin->blocks.hwmchain,0,sizeof(coin->blocks.hwmchain));
}
void iguana_coinpurge(struct iguana_info *coin)
{
9 years ago
int32_t i,saved; struct iguana_bundle *bp; char *hashstr; struct iguana_bundlereq *req; struct iguana_blockreq *breq; struct iguana_helper *ptr;
saved = coin->active, coin->active = 0;
coin->started = 0;
9 years ago
while ( coin->idletime == 0 && coin->emitbusy > 0 )
{
printf("coinpurge.%s waiting for idle %lu emitbusy.%d\n",coin->symbol,time(NULL),coin->emitbusy);
sleep(1);
}
9 years ago
coin->RTgenesis = 0;
9 years ago
while ( (ptr= queue_dequeue(&bundlesQ,0)) != 0 )
myfree(ptr,ptr->allocsize);
9 years ago
if ( 1 )
9 years ago
{
9 years ago
while ( (hashstr= queue_dequeue(&coin->hdrsQ,1)) != 0 )
free_queueitem(hashstr);
while ( (breq= queue_dequeue(&coin->blocksQ,0)) != 0 )
myfree(breq,sizeof(*breq));
while ( (breq= queue_dequeue(&coin->priorityQ,0)) != 0 )
myfree(breq,sizeof(*breq));
while ( (req= queue_dequeue(&coin->cacheQ,0)) != 0 )
myfree(req,req->allocsize);
while ( (req= queue_dequeue(&coin->recvQ,0)) != 0 )
{
if ( req->blocks != 0 )
myfree(req->blocks,sizeof(*req->blocks) * req->n), req->blocks = 0;
9 years ago
if ( req->hashes != 0 )
9 years ago
myfree(req->hashes,sizeof(*req->hashes) * req->n), req->hashes = 0;
myfree(req,req->allocsize);
}
9 years ago
}
iguana_RTramchainfree(coin);
coin->bundlescount = 0;
for (i=0; i<coin->bundlescount; i++)
if ( (bp= coin->bundles[i]) != 0 )
iguana_bundlepurge(coin,bp);
coin->current = coin->lastpending = 0;
memset(coin->bundles,0,sizeof(coin->bundles));
iguana_blockspurge(coin);
9 years ago
coin->active = saved;
9 years ago
}
9 years ago
struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialheight,int32_t mapflags)
9 years ago
{
9 years ago
FILE *fp; char fname[512],*symbol; int32_t iter; long fpos;
9 years ago
coin->sleeptime = 10000;
symbol = coin->symbol;
9 years ago
if ( iguana_peerslotinit(coin,&coin->internaladdr,IGUANA_MAXPEERS,calc_ipbits("127.0.0.1:7777")) < 0 )
{
printf("iguana_coinstart: error creating peerslot\n");
return(0);
}
9 years ago
if ( initialheight < coin->chain->bundlesize*10 )
initialheight = coin->chain->bundlesize*10;
iguana_recvalloc(coin,initialheight);
9 years ago
if ( coin->longestchain == 0 )
coin->longestchain = 1;
9 years ago
memset(&coin->blocks.hwmchain,0,sizeof(coin->blocks.hwmchain));
9 years ago
coin->blocks.hwmchain.height = 0;
9 years ago
printf("MYSERVICES.%llx\n",(long long)coin->myservices);
if ( (coin->myservices & NODE_NETWORK) != 0 && coin->peers.acceptloop == 0 && coin->peers.localaddr == 0 )
9 years ago
{
9 years ago
coin->peers.acceptloop = malloc(sizeof(pthread_t));
if ( OS_thread_create(coin->peers.acceptloop,NULL,(void *)iguana_acceptloop,(void *)coin) != 0 )
{
free(coin->peers.acceptloop);
coin->peers.acceptloop = 0;
printf("error launching accept thread for port.%u\n",coin->chain->portp2p);
}
9 years ago
}
9 years ago
//coin->firstblock = coin->blocks.parsedblocks + 1;
9 years ago
iguana_genesis(coin,coin->chain);
9 years ago
for (iter=coin->peers.numranked>8; iter<2; iter++)
9 years ago
{
9 years ago
#ifdef __PNACL__
#include "confs/BTCD_hdrs.h"
bits256 hash2,allhash,hash1; int32_t bundlei,i,height; struct iguana_block *block; struct iguana_bundle *bp;
for (i=0; i<sizeof(BTCD_hdrs)/sizeof(*BTCD_hdrs); i++)
{
height = atoi(BTCD_hdrs[i][0]);
if ( height > (coin->blocks.maxbits - 1000) )
iguana_recvalloc(coin,height + 100000);
hash2 = bits256_conv(BTCD_hdrs[i][1]);
if ( BTCD_hdrs[i][2][0] != 0 )
allhash = bits256_conv(BTCD_hdrs[i][2]);
if ( BTCD_hdrs[i][3][0] != 0 )
hash1 = bits256_conv(BTCD_hdrs[i][3]);
if ( (bp= iguana_bundlecreate(coin,&bundlei,height,hash2,allhash,0)) != 0 )
{
bp->bundleheight = height;
if ( bits256_nonz(hash1) != 0 )
{
if ( (block= iguana_blockhashset("inithash1",coin,height+1,hash1,1)) != 0 )
{
iguana_bundlehashadd(coin,bp,1,block);
block->mainchain = 1;
}
}
}
}
#endif
9 years ago
sprintf(fname,"confs/%s_%s.txt",coin->symbol,(iter == 0) ? "peers" : "hdrs");
9 years ago
OS_compatible_path(fname);
//sprintf(fname,"confs/%s_%s.txt",coin->symbol,(iter == 0) ? "peers" : "hdrs");
9 years ago
//sprintf(fname,"tmp/%s/%s.txt",coin->symbol,(iter == 0) ? "peers" : "hdrs");
9 years ago
OS_compatible_path(fname);
printf("parsefile.%d %s\n",iter,fname);
9 years ago
if ( (fp= fopen(fname,"r")) != 0 )
9 years ago
{
iguana_parseline(coin,iter,fp);
9 years ago
fpos = ftell(fp);
9 years ago
fclose(fp);
9 years ago
} else fpos = -1;
9 years ago
printf("done parsefile.%d (%s) size.%ld\n",iter,fname,fpos);
9 years ago
}
#ifndef IGUANA_DEDICATED_THREADS
coin->peers.peersloop = iguana_launch("peersloop",iguana_peersloop,coin,IGUANA_PERMTHREAD);
#endif
9 years ago
printf("started.%s %p active.%d\n",coin->symbol,coin->started,coin->active);
9 years ago
return(coin);
}