Browse Source

debug prints

release/v0.1
jl777 8 years ago
parent
commit
e08c7e16ab
  1. 2
      basilisk/basilisk.c
  2. 2
      deprecated/iguana_instantdex.c
  3. 4
      iguana/coins/basilisk
  4. 42
      iguana/iguana777.c
  5. 2
      iguana/iguana_bitmap.c
  6. 2
      iguana/iguana_blocks.c
  7. 4
      iguana/iguana_bundles.c
  8. 2
      iguana/iguana_exchanges.c
  9. 2
      iguana/iguana_mofn.c
  10. 32
      iguana/iguana_msg.c
  11. 26
      iguana/iguana_peers.c
  12. 28
      iguana/iguana_ramchain.c
  13. 17
      iguana/iguana_spendvectors.c
  14. 24
      iguana/iguana_volatiles.c
  15. 33
      iguana/main.c
  16. 2
      iguana/peggy.c
  17. 2
      iguana/peggy_accts.c
  18. 2
      iguana/peggy_txind.c
  19. 1
      includes/iguana_funcs.h
  20. 2
      includes/iguana_globals.h

2
basilisk/basilisk.c

@ -229,7 +229,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
}
if ( s == n && valid == 1 && (destipaddr == 0 || strcmp(addr->ipaddr,destipaddr) == 0) )
{
//printf("n.%d/fanout.%d i.%d l.%d [%s].tag%d send %s.(%s) [%x] datalen.%d addr->supernet.%u basilisk.%u to (%s).%d destip.%s\n",n,fanout,i,l,cmd,*(uint32_t *)data,type,(char *)&data[4],*(int32_t *)&data[datalen-4],datalen,addr->supernet,addr->basilisk,addr->ipaddr,addr->A.port,destipaddr!=0?destipaddr:"broadcast");
printf("n.%d/fanout.%d i.%d l.%d [%s].tag%d send %s.(%s) [%x] datalen.%d addr->supernet.%u basilisk.%u to (%s).%d destip.%s\n",n,fanout,i,l,cmd,*(uint32_t *)data,type,(char *)&data[4],*(int32_t *)&data[datalen-4],datalen,addr->supernet,addr->basilisk,addr->ipaddr,addr->A.port,destipaddr!=0?destipaddr:"broadcast");
if ( encryptflag != 0 && bits256_nonz(addr->pubkey) != 0 )
{
void *ptr; uint8_t *cipher,space[8192]; int32_t cipherlen; bits256 privkey;

2
deprecated/iguana_instantdex.c

@ -225,7 +225,7 @@ struct instantdex_event *instantdex_addevent(struct instantdex_stateinfo *states
for (i=0; i<numstates; i++)
printf("%s[%d] ",states[i].name,i);
printf("cant add event (%s -> %s) without existing state and nextstate\n",statename,nextstatename);
exit(-1);
iguana_exit(0);
return(0);
}
}

4
iguana/coins/basilisk

@ -1,4 +1,4 @@
curl --url "http://127.0.0.1:7778" --data "{\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":14631}"
curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":8333}"
curl --url "http://127.0.0.1:7778" --data "{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":11,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"newcoin\":\"LTC\",\"name\":\"Litecoin\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"fbc0b6db\",\"p2p\":9333,\"rpc\":9334,\"pubval\":48,\"p2shval\":5,\"wifval\":176,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2\",\"genesis\":{\"version\":1,\"timestamp\":1317972665,\"nBits\":\"1e0ffff0\",\"nonce\":2084524493,\"merkle_root\":\"97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9\"},\"alertpubkey\":\"040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9\",\"protover\":70002}"
#curl --url "http://127.0.0.1:7778" --data "{\"prefetchlag\":5,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTC\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":8333}"
#curl --url "http://127.0.0.1:7778" --data "{\"RELAY\":0,\"VALIDATE\":0,\"prefetchlag\":11,\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"newcoin\":\"LTC\",\"name\":\"Litecoin\",\"hasheaders\":1,\"useaddmultisig\":0,\"netmagic\":\"fbc0b6db\",\"p2p\":9333,\"rpc\":9334,\"pubval\":48,\"p2shval\":5,\"wifval\":176,\"txfee_satoshis\":\"100000\",\"isPoS\":0,\"minoutput\":10000,\"minconfirms\":2,\"genesishash\":\"12a765e31ffd4059bada1e25190f6e98c99d9714d334efa41a195a7e7e04bfe2\",\"genesis\":{\"version\":1,\"timestamp\":1317972665,\"nBits\":\"1e0ffff0\",\"nonce\":2084524493,\"merkle_root\":\"97ddfbbae6be97fd6cdf3e7ca13232a3afff2353e29badfab7f73011edd4ced9\"},\"alertpubkey\":\"040184710fa689ad5023690c80f3a49c8f13f8d45b8c857fbcbc8bc4a8e4d3eb4b10f4d4604fa08dce601aaf0f470216fe1b51850b4acf21b179c45070ac7b03a9\",\"protover\":70002}"

42
iguana/iguana777.c

@ -27,8 +27,10 @@ struct iguana_info *iguana_coinfind(char *symbol)
struct iguana_info *coin=0; uint32_t symbolcrc; struct supernet_info *myinfo = SuperNET_MYINFO(0);
while ( myinfo->allcoins_being_added != 0 )
{
sleep(3);
if ( myinfo->allcoins_being_added != 0 )
printf("wait for coinadd to complete, OK if rare\n");
sleep(1);
sleep(3);
}
symbolcrc = calc_crc32(0,symbol,(int32_t)strlen(symbol));
//portable_mutex_lock(&myinfo->allcoins_mutex);
@ -401,7 +403,7 @@ int32_t iguana_helperA(struct supernet_info *myinfo,struct iguana_info *coin,int
else
{
printf("error validating.[%d], restart iguana\n",bp->hdrsi);
exit(-1);
iguana_exit(myinfo);
}
return(num);
}
@ -517,7 +519,7 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int
if ( iguana_bundlevalidate(myinfo,coin,bp,0) != bp->n )
{
printf("validate.[%d] error. refresh page or restart iguana and it should regenerate\n",bp->hdrsi);
exit(-1);
iguana_exit(myinfo);
} // else printf("%s helperid.%d validated.[%d]\n",coin->symbol,helperid,hdrsi);
}
}
@ -567,7 +569,7 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int
if ( iguana_utxoaddr_gen(myinfo,coin,(coin->bundlescount - 1) * coin->chain->bundlesize) == 0 )
{
printf("restart iguana: fatal error generating ledger file for %s\n",coin->symbol);
exit(1);
iguana_exit(myinfo);
}
}
}
@ -781,7 +783,7 @@ void iguana_callcoinstart(struct supernet_info *myinfo,struct iguana_info *coin)
void iguana_coinloop(void *arg)
{
struct supernet_info *myinfo; int32_t flag,i,n; bits256 zero; uint32_t now; struct iguana_info *coin,**coins = arg;
struct supernet_info *myinfo; int32_t flag,i,j,n; struct iguana_peer *addr; bits256 zero; uint32_t now; struct iguana_info *coin,**coins = arg;
myinfo = SuperNET_MYINFO(0);
n = (int32_t)(long)coins[0];
coins++;
@ -800,8 +802,7 @@ void iguana_coinloop(void *arg)
if ( coin->peers == 0 )
{
printf("FATAL lack of peers struct\n");
exit(-1);
iguana_launchpeer(coin,"127.0.0.1",1);
iguana_exit(myinfo);
}
if ( coin->virtualchain == 0 )
{
@ -832,13 +833,7 @@ void iguana_coinloop(void *arg)
if ( coin->MAXPEERS > IGUANA_MINPEERS )
coin->MAXPEERS = IGUANA_MINPEERS;
}
/*if ( coin->isRT != 0 && coin->current != 0 && coin->numverified >= coin->current->hdrsi )
{
//static int32_t saved;
//if ( saved++ == 0 )
// iguana_coinflush(coin,1);
}*/
if ( RELAYID >= 0 )
if ( RELAYID < 0 )
{
if ( coin->bindsock >= 0 )
{
@ -854,8 +849,25 @@ void iguana_coinloop(void *arg)
{
if ( coin->MAXPEERS > 1 && coin->peers->numranked < ((7*coin->MAXPEERS)>>3) && now > coin->lastpossible+10 )
{
if ( coin->peers->numranked > 0 && (now % 60) == 0 )
if ( coin->peers != 0 )
{
for (j=0; j<IGUANA_MAXPEERS; j++)
{
i = rand() % IGUANA_MAXPEERS;
addr = &coin->peers->active[(i+j) % IGUANA_MAXPEERS];
if ( addr->usock >= 0 && addr->msgcounts.verack == 0 )
{
printf("i.%d j.%d mainloop %s\n",i,j,addr->ipaddr);
iguana_send_version(coin,addr,coin->myservices);
break;
}
}
}
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 )
{
if ( coin->peers->numranked > 0 )
iguana_send_ping(myinfo,coin,coin->peers->ranked[rand() % coin->peers->numranked]);
}
coin->lastpossible = iguana_possible_peer(coin,0); // tries to connect to new peers
}
}

2
iguana/iguana_bitmap.c

@ -126,7 +126,7 @@ void gen_jpegfile(char *fname,int32_t quality,uint8_t *bitmap,int32_t width,int3
if ( (outfile= fopen(fname,"wb")) == NULL)
{
fprintf(stderr, "can't open %s\n", fname);
exit(1);
iguana_exit(0);
}
jpeg_stdio_dest(&cinfo, outfile);
cinfo.image_width = width; /* image width and height, in pixels */

2
iguana/iguana_blocks.c

@ -150,7 +150,7 @@ void _iguana_blocklink(struct iguana_info *coin,struct iguana_block *prev,struct
if ( memcmp(block->RO.prev_block.bytes,prev->RO.hash2.bytes,sizeof(bits256)) != 0 )
{
printf("illegal blocklink mismatched hashes\n");
exit(-1);
iguana_exit(0);
return;
}
block->hh.prev = prev;

4
iguana/iguana_bundles.c

@ -591,7 +591,7 @@ struct iguana_block *iguana_bundleblock(struct iguana_info *coin,bits256 *hash2p
if ( len > (sizeof(int32_t) + sizeof(*hashes))*n + 1024 )
{
printf("FATAL ERROR iguana_sendhashes: len.%d size.%ld\n",len,(sizeof(int32_t) + sizeof(*hashes))*n + 1024);
exit(-1);
iguana_exit(myinfo);
}
iguana_send(coin,addr,serialized,len);
coin->numreqsent += n;
@ -1548,7 +1548,7 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch
fprintf(logfp,"%s bQ.%d %d:%02d:%02d stuck.%d max.%d\n",str,numbQ,(int32_t)difft.x/3600,(int32_t)(difft.x/60)%60,(int32_t)difft.x%60,coin->stucktime!=0?(uint32_t)time(NULL) - coin->stucktime:0,coin->maxstuck);
fflush(logfp);
}
printf("%s bQ.%d %d:%02d:%02d stuck.%d max.%d\n",str,numbQ,(int32_t)difft.x/3600,(int32_t)(difft.x/60)%60,(int32_t)difft.x%60,coin->stucktime!=0?(uint32_t)time(NULL) - coin->stucktime:0,coin->maxstuck);
//printf("%s bQ.%d %d:%02d:%02d stuck.%d max.%d\n",str,numbQ,(int32_t)difft.x/3600,(int32_t)(difft.x/60)%60,(int32_t)difft.x%60,coin->stucktime!=0?(uint32_t)time(NULL) - coin->stucktime:0,coin->maxstuck);
strcpy(coin->lastdispstr,str);
if ( (rand() % 100) == 0 )
myallocated(0,0);

2
iguana/iguana_exchanges.c

@ -1035,7 +1035,7 @@ struct exchange_info *exchange_create(char *exchangestr,cJSON *argjson)
if ( stringbits((char *)Exchange_funcs[i]->name) == stringbits((char *)Exchange_funcs[j]->name) )
{
printf("FIRST 8 chars of Exchange_func[].name must be unique: %d.(%s) vs %d.(%s)\n",i,Exchange_funcs[i]->name,j,Exchange_funcs[j]->name);
exit(-1);
iguana_exit(0);
}
}
didinit = 1;

2
iguana/iguana_mofn.c

@ -656,7 +656,7 @@ bits256 iguana_schnorr_noncepair(void *ctx,bits256 *pubkey,uint8_t odd_even,bits
if ( j == maxj )
{
printf("couldnt generate even noncepair\n");
exit(-1);
iguana_exit(0);
}
return(privnonce);
}

32
iguana/iguana_msg.c

@ -310,17 +310,13 @@ int32_t iguana_rwmsgalert(struct iguana_info *coin,int32_t rwflag,uint8_t *seria
void iguana_gotversion(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct iguana_msgversion *vers)
{
uint8_t serialized[sizeof(struct iguana_msghdr)]; char *retstr;
//printf("gotversion from %s: starting height.%d services.%llx proto.%d (%s)\n",addr->ipaddr,vers->nStartingHeight,(long long)vers->nServices,vers->nVersion,vers->strSubVer);
if ( 0 && strncmp(vers->strSubVer,"/iguana",strlen("/iguana")) == 0 )
{
uint8_t serialized[sizeof(struct iguana_msghdr)];
printf("gotversion from %s: starting height.%d services.%llx proto.%d (%s)\n",addr->ipaddr,vers->nStartingHeight,(long long)vers->nServices,vers->nVersion,vers->strSubVer);
if ( strncmp(vers->strSubVer,"/iguana",strlen("/iguana")) == 0 )
addr->supernet = 1, addr->basilisk = 0;
if ( (retstr= basilisk_addrelay_info(myinfo,0,(uint32_t)addr->ipbits,GENESIS_PUBKEY)) != 0 )
free(retstr);
}
else if ( strncmp(vers->strSubVer,"/basilisk",strlen("/basilisk")) == 0 )
addr->basilisk = 1, addr->supernet = 0;
if ( (vers->nServices & NODE_NETWORK) != 0 )
//if ( (vers->nServices & NODE_NETWORK) != 0 )
{
addr->protover = (vers->nVersion < PROTOCOL_VERSION) ? vers->nVersion : PROTOCOL_VERSION;
//printf("(%s) proto.%d -> %d\n",addr->ipaddr,vers->nVersion,addr->protover);
@ -328,12 +324,9 @@ void iguana_gotversion(struct supernet_info *myinfo,struct iguana_info *coin,str
addr->height = vers->nStartingHeight;
addr->relayflag = 1;
iguana_gotdata(coin,addr,addr->height);
iguana_queue_send(addr,0,serialized,"verack",0);
//iguana_send_ping(coin,addr);
}
else if ( 0 && addr->supernet == 0 && addr->basilisk == 0 )//|| (addr->basilisk != 0 && myinfo->IAMRELAY == 0) )
addr->dead = (uint32_t)time(NULL);
if ( addr->supernet != 0 || addr->basilisk != 0 )
iguana_queue_send(addr,0,serialized,"verack",0);
//if ( addr->supernet != 0 || addr->basilisk != 0 )
printf("height.%d nServices.%lld nonce.%llu %srelay node.(%s) supernet.%d basilisk.%d longest.%u\n",vers->nStartingHeight,(long long)vers->nServices,(long long)vers->nonce,addr->relayflag==0?"non-":"",addr->ipaddr,addr->supernet,addr->basilisk,vers->nStartingHeight);
if ( (int32_t)vers->nStartingHeight > coin->longestchain )
{
@ -357,7 +350,7 @@ int32_t iguana_send_version(struct iguana_info *coin,struct iguana_peer *addr,ui
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 )
sprintf(msg.strSubVer,"/iguana 0.00/");
else sprintf(msg.strSubVer,"/basilisk 0.00/");
//printf("SEND.(%s) -> (%s)\n",msg.strSubVer,addr->ipaddr);
printf("SEND.(%s) -> (%s)\n",msg.strSubVer,addr->ipaddr);
//sprintf(msg.strSubVer,"/Satoshi:0.10.0/");
msg.nStartingHeight = coin->blocks.hwmchain.height;
iguana_gotdata(coin,addr,msg.nStartingHeight);
@ -398,7 +391,7 @@ void iguana_gotverack(struct supernet_info *myinfo,struct iguana_info *coin,stru
uint8_t serialized[sizeof(struct iguana_msghdr)];
if ( addr != 0 )
{
//printf("gotverack from %s\n",addr->ipaddr);
printf("gotverack from %s\n",addr->ipaddr);
addr->A.nTime = (uint32_t)time(NULL);
iguana_queue_send(addr,0,serialized,"getaddr",0);
iguana_supernet_ping(myinfo,coin,addr);
@ -440,6 +433,11 @@ void iguana_gotping(struct supernet_info *myinfo,struct iguana_info *coin,struct
int32_t iguana_send_ping(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr)
{
int32_t len; uint64_t nonce; uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(nonce)];
if ( addr->msgcounts.verack == 0 )
{
printf("send version instead of ping to %s\n",addr->ipaddr);
return(iguana_send_version(coin,addr,coin->myservices));
}
if ( (nonce= addr->pingnonce) == 0 )
{
OS_randombytes((uint8_t *)&nonce,sizeof(nonce));
@ -887,8 +885,8 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s
}
if ( addr != 0 )
{
if ( 0 && strcmp("DOGE",coin->symbol) == 0 )
printf("iguana_msgparser from (%s) parse.(%s) len.%d\n",addr->ipaddr,H->command,recvlen);
//if ( 0 && strcmp("DOGE",coin->symbol) == 0 )
printf("iguana_msgparser verack.%d from (%s) parse.(%s) len.%d\n",addr->msgcounts.verack,addr->ipaddr,H->command,recvlen);
//iguana_peerblockrequest(coin,addr->blockspace,IGUANA_MAXPACKETSIZE,addr,iguana_blockhash(coin,100),0);
addr->lastcontact = (uint32_t)time(NULL);
strcpy(addr->lastcommand,H->command);

26
iguana/iguana_peers.c

@ -88,7 +88,10 @@ struct iguana_iAddr *_iguana_hashset(struct iguana_info *coin,uint32_t ipbits,in
ptr = iguana_memalloc(mem,allocsize,1);
else ptr = mycalloc('t',1,allocsize);
if ( ptr == 0 )
printf("fatal alloc errorA in hashset\n"), exit(-1);
{
printf("fatal alloc errorA in hashset\n");
iguana_exit(0);
}
//printf("ptr.%p allocsize.%d key.%p keylen.%d itemind.%d\n",ptr,allocsize,key,keylen,itemind);
ptr->hh.itemind = itemind;
ptr->ipbits = ipbits;
@ -114,7 +117,7 @@ struct iguana_iAddr *iguana_iAddrhashset(struct iguana_info *coin,struct iguana_
if ( iA == 0 || iA->ipbits == 0 )
{
printf("null iA.%p or ipbits.%llx ind.%d status.%d\n",iA,iA!=0?(long long)iA->ipbits:0,iA!=0?iA->hh.itemind:0,iA!=0?iA->status:0);
exit(-1);
iguana_exit(0);
return(0);
}
portable_mutex_lock(&coin->peers_mutex);
@ -189,7 +192,10 @@ uint32_t iguana_rwiAddrind(struct iguana_info *coin,int32_t rwflag,struct iguana
{
ptr = mycalloc('t',1,sizeof(*ptr));
if ( ptr == 0 )
printf("fatal alloc errorB in hashset\n"), exit(-1);
{
printf("fatal alloc errorB in hashset\n");
iguana_exit(0);
}
ptr->hh.itemind = m;
ptr->ipbits = tmp.ipbits;
HASH_ADD(hh,coin->iAddrs,ipbits,sizeof(ipbits),ptr);
@ -475,9 +481,10 @@ int32_t iguana_send(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *s
}
else if ( addr->msgcounts.verack == 0 && (strcmp(cmdstr,"version") != 0 && strcmp(cmdstr,"ConnectTo") != 0 && strcmp(cmdstr,"verack") != 0) != 0 )
{
//printf("skip.(%s) since no verack yet\n",cmdstr);
printf("skip.(%s) since no verack yet\n",cmdstr);
return(-1);
}
printf("%s -> %s\n",cmdstr,addr->ipaddr);
if ( strcmp(cmdstr,"ping") == 0 )
addr->sendmillis = OS_milliseconds();
if ( len > IGUANA_MAXPACKETSIZE )
@ -510,7 +517,7 @@ int32_t iguana_send(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *s
}
}
addr->totalsent += len;
//printf(" (%s) sent.%d bytes to %s\n",cmdstr,len,addr->ipaddr);// getchar();
printf(" (%s) sent.%d bytes to %s\n",cmdstr,len,addr->ipaddr);
return(len);
}
@ -520,7 +527,7 @@ int32_t iguana_queue_send(struct iguana_peer *addr,int32_t delay,uint8_t *serial
if ( addr == 0 )
{
printf("iguana_queue_send null addr\n");
exit(-1);
iguana_exit(0);
return(-1);
}
if ( (datalen= iguana_sethdr((void *)serialized,addr->netmagic,cmd,&serialized[sizeof(struct iguana_msghdr)],len)) < 0 )
@ -538,7 +545,7 @@ int32_t iguana_queue_send(struct iguana_peer *addr,int32_t delay,uint8_t *serial
packet->embargo.millis += delay;
}
memcpy(packet->serialized,serialized,datalen);
//printf("%p queue send.(%s) %d to (%s)\n",packet,serialized+4,datalen,addr->ipaddr);
printf("%p queue send.(%s) %d to (%s)\n",packet,serialized+4,datalen,addr->ipaddr);
queue_enqueue("sendQ",&addr->sendQ,&packet->DL,0);
return(datalen);
}
@ -1088,7 +1095,7 @@ int64_t iguana_peerfree(struct iguana_info *coin,struct iguana_peer *addr,void *
if ( iguana_memfree(mem,ptr,datalen) < 0 || (avail= iguana_peerallocated(coin,addr)) < 0 )
{
printf("iguana_peerfree: corrupted mem avail.%lld ptr.%p %d\n",(long long)avail,ptr,datalen);
exit(-1);
iguana_exit(myinfo);
}
return(avail);
}
@ -1202,8 +1209,9 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin,
}
else
{
sleep(1 + (rand() % 3));
printf("greeting send version myservices.%llu to (%s)\n",(long long)coin->myservices,addr->ipaddr);
iguana_send_version(coin,addr,coin->myservices);
//printf("send version myservices.%llu to (%s)\n",(long long)coin->myservices,addr->ipaddr);
}
//sleep(1+(rand()%5));
run = 0;

28
iguana/iguana_ramchain.c

@ -52,7 +52,10 @@ struct iguana_kvitem *iguana_hashsetPT(struct iguana_ramchain *ramchain,int32_t
printf("alloc.%d\n",allocsize);
}
if ( ptr == 0 )
printf("fatal alloc errorC in hashset\n"), exit(-1);
{
printf("fatal alloc errorC in hashset\n");
iguana_exit(0);
}
if ( 0 && ramchain->expanded && selector == 'T' )
printf("hashmem.%p selector.%c added.(%s) itemind.%x ptr.%p\n",ramchain->hashmem,selector,str,itemind,ptr);
if ( selector == 'T' )
@ -64,7 +67,10 @@ struct iguana_kvitem *iguana_hashsetPT(struct iguana_ramchain *ramchain,int32_t
if ( 0 && ramchain->expanded && selector == 'T' )
printf("selector.%c added.(%s) itemind.%x ptr.%p tmp.%p\n",selector,str,itemind,ptr,tmp);
if ( itemind == 0 )
printf("negative itemind\n"), exit(-1);
{
printf("negative itemind\n");
iguana_exit(0);
}
if ( 0 )
{
if ( selector == 'T' )
@ -72,7 +78,8 @@ struct iguana_kvitem *iguana_hashsetPT(struct iguana_ramchain *ramchain,int32_t
else HASH_FIND(hh,ramchain->pkhashes,key,keylen,tmp);
if ( tmp != ptr )
{
printf("(%s) hashmem.%p selector.%c %s search error %p != %p itemind.%x\n",str,ramchain->hashmem,selector,str,ptr,tmp,itemind), exit(-1);
printf("(%s) hashmem.%p selector.%c %s search error %p != %p itemind.%x\n",str,ramchain->hashmem,selector,str,ptr,tmp,itemind);
iguana_exit(0);
}
}
}
@ -226,7 +233,7 @@ uint32_t iguana_ramchain_addpkhash(struct iguana_info *coin,RAMCHAIN_FUNC,uint8_
if ( P[pkind].pkind != pkind ) //unspentind != 0 && (P[pkind].firstunspentind != unspentind ||
{
printf("iguana_ramchain_addpkhash error mismatched pkind.(%x %x) unspentind.%d\n",pkind,P[pkind].pkind,unspentind);
exit(-1);
iguana_exit(0);
return(0);
}
if ( memcmp(P[pkind].rmd160,rmd160,sizeof(P[pkind].rmd160)) != 0 )
@ -389,7 +396,7 @@ uint32_t iguana_ramchain_addunspent(struct iguana_info *coin,RAMCHAIN_FUNC,uint6
if ( u->fileid != fileid || u->scriptpos != fpos || u->scriptlen != scriptlen || u->value != value || u->pkind != pkind || u->value != value || u->txidind != ramchain->H.txidind || (pkind != 0 && u->prevunspentind != A[pkind].lastunspentind) || u->vout != vout || u->hdrsi != hdrsi )
{
printf("iguana_ramchain_addunspent: (%d %d %d) vs (%d %d %d) mismatched values.(%d %.8f %d %d %d %d) vs (%d %.8f %d %d %d %d)\n",u->fileid,u->scriptpos,u->scriptlen,fileid,fpos,scriptlen,u->pkind,dstr(u->value),u->txidind,u->prevunspentind,u->vout,u->hdrsi,pkind,dstr(value),ramchain->H.txidind,A[pkind].lastunspentind,vout,hdrsi);
exit(-1);
iguana_exit(0);
return(0);
}
}
@ -484,7 +491,12 @@ uint32_t iguana_ramchain_addspend(struct iguana_info *coin,RAMCHAIN_FUNC,bits256
return(0);
}
} else printf("addspend illegal unspentind.%d vs %d\n",unspentind,rdata->numunspents);
} else printf("addspend illegal txidind.%d vs %d\n",txidind,rdata->numtxids), exit(-1);
}
else
{
printf("addspend illegal txidind.%d vs %d\n",txidind,rdata->numtxids);
iguana_exit(0);
}
}
if ( ramchain->H.ROflag != 0 )
{
@ -986,7 +998,7 @@ int64_t iguana_ramchain_init(char *fname,struct iguana_ramchain *ramchain,struct
if ( rdata->allocsize != iguana_ramchain_size(fname,RAMCHAIN_ARG,numblocks,scriptspace,zcash) )
{
printf("offset.%ld scriptspace.%d allocsize.%ld vs memsize.%ld\n",(long)offset,scriptspace,(long)rdata->allocsize,(long)iguana_ramchain_size(fname,RAMCHAIN_ARG,numblocks,scriptspace,zcash));
exit(-1);
iguana_exit(0);
}
if ( offset <= mem->totalsize )
iguana_memreset(mem);
@ -1002,7 +1014,7 @@ int64_t iguana_ramchain_init(char *fname,struct iguana_ramchain *ramchain,struct
if ( rdata->allocsize > mem->totalsize )
{
printf("init.(%d %d %d %d %d) rdata->allocsize.%ld mem->totalsize.%ld hashmemsize.%ld\n",numtxids,numunspents,numspends,numpkinds,numexternaltxids,(long)rdata->allocsize,mem->totalsize,hashmem!=0?hashmem->totalsize:0);
exit(-1);
iguana_exit(0);
}
return(offset);
}

17
iguana/iguana_spendvectors.c

@ -97,7 +97,7 @@ int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp
return(retval);
}
struct iguana_bundle *iguana_externalspent(struct iguana_info *coin,bits256 *prevhashp,uint32_t *unspentindp,struct iguana_ramchain *ramchain,int32_t spent_hdrsi,struct iguana_spend *s,int32_t prefetchflag)
struct iguana_bundle *iguana_externalspent(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *prevhashp,uint32_t *unspentindp,struct iguana_ramchain *ramchain,int32_t spent_hdrsi,struct iguana_spend *s,int32_t prefetchflag)
{
int32_t prev_vout,height,hdrsi; uint32_t sequenceid,unspentind; char str[65]; struct iguana_bundle *spentbp=0; struct iguana_txid *T,TX,*tp; bits256 *X; bits256 prev_hash; struct iguana_ramchaindata *rdata;
if ( (rdata= ramchain->H.data) != 0 )
@ -155,7 +155,8 @@ struct iguana_bundle *iguana_externalspent(struct iguana_info *coin,bits256 *pre
else
{
printf("illegal hdrsi.%d prev_hash.(%s) for bp.[%d]\n",hdrsi,bits256_str(str,prev_hash),spent_hdrsi);
exit(-1);
iguana_exit(myinfo);
return(0);
}
}
else
@ -164,7 +165,7 @@ struct iguana_bundle *iguana_externalspent(struct iguana_info *coin,bits256 *pre
if ( spent_hdrsi < coin->current->hdrsi )
{
iguana_bundleremove(coin,spent_hdrsi,1);
exit(-1);
iguana_exit(myinfo);
}
coin->RTdatabad = 1;
return(0);
@ -177,6 +178,7 @@ struct iguana_bundle *iguana_externalspent(struct iguana_info *coin,bits256 *pre
printf("%s illegal unspentind.%d vs max.%d spentbp.%p[%d]\n",coin->symbol,unspentind,spentbp->ramchain.H.data->numunspents,spentbp,hdrsi);
else return(spentbp);
iguana_bundleremove(coin,spent_hdrsi,1);
iguana_exit(myinfo);
}
//exit(-1);
return(0);
@ -315,7 +317,7 @@ int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coi
}
else if ( spentbp == 0 )
{
if ( (spentbp= iguana_externalspent(coin,&prevhash,&spent_unspentind,ramchain,bp->hdrsi,s,2)) != 0 )
if ( (spentbp= iguana_externalspent(myinfo,coin,&prevhash,&spent_unspentind,ramchain,bp->hdrsi,s,2)) != 0 )
{
if ( coin->fastfind != 0 )
printf("found prevhash using slow, not fast\n");
@ -955,12 +957,7 @@ int32_t iguana_balanceflush(struct supernet_info *myinfo,struct iguana_info *coi
}
}
#endif
for (i=0; i<30; i++)
{
printf("need to exit, please restart after shutdown in %d seconds, or just ctrl-C\n",30-i);
sleep(1);
}
exit(-1);
iguana_exit(myinfo);
}
coin->balanceswritten = iguana_volatilesinit(myinfo,coin);
//printf("flush free\n");

24
iguana/iguana_volatiles.c

@ -315,30 +315,10 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc
{
//double startmillis = OS_milliseconds(); static double totalmillis; static int32_t utxon;
printf("hhutxo deprecated\n");
exit(-1);
/*spentP = RAMCHAIN_PTR(rdata,Poffset);
spentU = RAMCHAIN_PTR(rdata,Uoffset);
if ( iguana_utxoupdate(coin,spent_hdrsi,spent_unspentind,spent_pkind,spent_value,spendind,fromheight,spentP[spent_pkind].rmd160) == 0 )
{
//totalmillis += (OS_milliseconds() - startmillis);
// if ( (++utxon % 100000) == 0 )
// printf("ave utxo[%d] %.2f micros total %.2f seconds\n",utxon,(1000. * totalmillis)/utxon,totalmillis/1000.);
//portable_mutex_unlock(&coin->RTmutex);
return(0);
}*/
iguana_exit(0);
}
//portable_mutex_unlock(&coin->RTmutex);
printf("end iguana_volatileupdate.%d: [%d] spent.(u%u %.8f pkind.%d) double spend? at ht.%d [%d] spendind.%d (%p %p)\n",incremental,spent_hdrsi,spent_unspentind,dstr(spent_value),spent_pkind,fromheight,fromheight/coin->chain->bundlesize,spendind,spentchain->Uextras,spentchain->A2);
/*if ( coin->current != 0 && fromheight >= coin->current->bundleheight )
coin->RTdatabad = 1;
else
{
printf("from.%d vs current.%d\n",fromheight,coin->current->bundleheight);
iguana_bundleremove(coin,fromheight/coin->chain->bundlesize,0);
}
coin->spendvectorsaved = 0;
coin->started = 0;
coin->active = 0;*/
coin->RTdatabad = 1;
if ( coin->current != 0 && spent_hdrsi != coin->current->hdrsi && spent_hdrsi != fromheight/coin->chain->bundlesize )
{
@ -356,7 +336,7 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc
bp->ramchain.H.data = 0;
}
portable_mutex_unlock(&coin->special_mutex);
exit(-1);
iguana_exit(0);
}
}
else if ( coin->spendvectorsaved > 1 )

33
iguana/main.c

@ -332,18 +332,19 @@ char *SuperNET_JSON(struct supernet_info *myinfo,struct iguana_info *coin,cJSON
return(retstr);
}
void iguana_exit()
void iguana_exit(struct supernet_info *myinfo)
{
int32_t j,iter; struct iguana_info *coin,*tmp;
int32_t i,j,iter; struct iguana_info *coin,*tmp;
if ( myinfo == 0 )
myinfo = SuperNET_MYINFO(0);
printf("start EXIT\n");
for (iter=0; iter<3; iter++)
{
if ( iter == 0 )
basilisk_request_goodbye(SuperNET_MYINFO(0));
basilisk_request_goodbye(myinfo);
else
{
//portable_mutex_lock(&Allcoins_mutex);
HASH_ITER(hh,Allcoins,coin,tmp)
HASH_ITER(hh,myinfo->allcoins,coin,tmp)
{
if ( coin->peers != 0 )
{
@ -360,22 +361,26 @@ void iguana_exit()
}
}
}
//portable_mutex_unlock(&Allcoins_mutex);
}
sleep(3);
}
printf("sockets closed, now EXIT\n");
printf("sockets closed\n");
for (i=0; i<10; i++)
{
printf("need to exit, please restart after shutdown in %d seconds, or just ctrl-C\n",10-i);
sleep(1);
}
exit(0);
}
#ifndef _WIN32
#include <signal.h>
void sigint_func() { printf("\nSIGINT\n"); iguana_exit(); }
void sigillegal_func() { printf("\nSIGILL\n"); iguana_exit(); }
void sighangup_func() { printf("\nSIGHUP\n"); iguana_exit(); }
void sigkill_func() { printf("\nSIGKILL\n"); iguana_exit(); }
void sigabort_func() { printf("\nSIGABRT\n"); iguana_exit(); }
void sigquit_func() { printf("\nSIGQUIT\n"); iguana_exit(); }
void sigint_func() { printf("\nSIGINT\n"); iguana_exit(0); }
void sigillegal_func() { printf("\nSIGILL\n"); iguana_exit(0); }
void sighangup_func() { printf("\nSIGHUP\n"); iguana_exit(0); }
void sigkill_func() { printf("\nSIGKILL\n"); iguana_exit(0); }
void sigabort_func() { printf("\nSIGABRT\n"); iguana_exit(0); }
void sigquit_func() { printf("\nSIGQUIT\n"); iguana_exit(0); }
void sigchild_func() { printf("\nSIGCHLD\n"); signal(SIGCHLD,sigchild_func); }
void sigalarm_func() { printf("\nSIGALRM\n"); signal(SIGALRM,sigalarm_func); }
void sigcontinue_func() { printf("\nSIGCONT\n"); signal(SIGCONT,sigcontinue_func); }
@ -1160,7 +1165,7 @@ ZERO_ARGS(SuperNET,stop)
{
if ( remoteaddr == 0 || strncmp(remoteaddr,"127.0.0.1",strlen("127.0.0.1")) == 0 )
{
iguana_exit();
iguana_exit(myinfo);
return(clonestr("{\"result\":\"exit started\"}"));
} else return(clonestr("{\"error\":\"cant do a remote stop of this node\"}"));
}

2
iguana/peggy.c

@ -701,7 +701,7 @@ void peggy_indsinit()
{
peggy_geninds();
printf("need to update Peggy_inds with above\n");
exit(-1);
iguana_exit(0);
}
peggy_dailyrates();
}

2
iguana/peggy_accts.c

@ -99,7 +99,7 @@ struct accts777_info *accts777_init(char *dirname,struct txinds777_info *txinds)
if ( accts->numkvs > ACCTS777_MAXRAMKVS )
{
printf("too many ramkvs for accts %d vs %d\n",accts->numkvs,ACCTS777_MAXRAMKVS);
exit(-1);
iguana_exit(0);
}
accts->addrkvs[PEGGY_ADDRFUNDING] = accts->addrkvs[PEGGY_ADDRBTCD] = accts->coinaddrs;
accts->addrkvs[PEGGY_ADDR777] = accts->SaMaddrs;

2
iguana/peggy_txind.c

@ -186,7 +186,7 @@ void opreturns_emitloop(char *protocols[],int32_t numprotocols,uint8_t opreturnd
if ( (opreturnlen= opreturns_emit(protocols[i],opreturndata,payments,max,currentblocknum,blocknum,blocktimestamp)) < 0 )
{
printf("opreturns_emitloop: error on protocol.(%s)\n",protocols[i]);
exit(-1);
iguana_exit(0);
}
if ( opreturnlen > 0 )
{

1
includes/iguana_funcs.h

@ -187,6 +187,7 @@ int32_t iguana_rpctest(struct iguana_info *coin);
extern queue_t helperQ;
extern const char *Hardcoded_coins[][3];
void iguana_main(void *arg);
void iguana_exit(struct supernet_info *myinfo);
int32_t iguana_peerfname(struct iguana_info *coin,int32_t *hdrsip,char *dirname,char *fname,uint32_t ipbits,bits256 hash2,bits256 prevhash2,int32_t numblocks,int32_t dispflag);
struct iguana_txblock *iguana_peertxdata(struct iguana_info *coin,int32_t *bundleip,char *fname,struct OS_memspace *mem,uint32_t ipbits,bits256 hash2);

2
includes/iguana_globals.h

@ -62,7 +62,7 @@ CONDEXTERN char *Iguana_validcommands[];
CONDEXTERN int32_t Showmode,Autofold,PANGEA_MAXTHREADS,QUEUEITEMS;
CONDEXTERN struct gecko_chain *Categories;
CONDEXTERN struct iguana_info *Allcoins;
//CONDEXTERN struct iguana_info *Allcoins;
CONDEXTERN char Userhome[512];
CONDEXTERN int32_t USE_JAY,FIRST_EXTERNAL,IGUANA_disableNXT,Debuglevel,IGUANA_BIGENDIAN;
CONDEXTERN uint32_t prices777_NXTBLOCK;

Loading…
Cancel
Save