Browse Source

fix basilisk script

release/v0.1
jl777 8 years ago
parent
commit
2901e349b8
  1. 2
      iguana/coins/basilisk
  2. 29
      iguana/iguana_init.c
  3. 9
      iguana/iguana_msg.c
  4. 2
      iguana/iguana_peers.c
  5. 4
      includes/iguana_structs.h

2
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 "{\"poll\":100,\"active\":1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":16,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632}"
#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 "{\"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 "{\"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}"

29
iguana/iguana_init.c

@ -106,41 +106,42 @@ bits256 iguana_genesis(struct supernet_info *myinfo,struct iguana_info *coin,str
return(hash2); return(hash2);
} }
decode_hex(buf,(int32_t)strlen(chain->genesis_hex)/2,(char *)chain->genesis_hex); decode_hex(buf,(int32_t)strlen(chain->genesis_hex)/2,(char *)chain->genesis_hex);
hash2 = iguana_calcblockhash(coin->symbol,coin->chain->hashalgo,buf,sizeof(struct iguana_msgblockhdr)); hash2 = iguana_calcblockhash(coin->symbol,coin->chain->hashalgo,buf,chain->zcash == 0 ? sizeof(struct iguana_msgblockhdr) : sizeof(struct iguana_msgzblockhdr));
auxback = coin->chain->auxpow, coin->chain->auxpow = 0; auxback = chain->auxpow, chain->auxpow = 0;
iguana_rwblock(myinfo,coin->symbol,coin->chain->zcash,coin->chain->auxpow,coin->chain->hashalgo,0,&hash2,buf,(void *)&zmsg,sizeof(buf)); iguana_rwblock(myinfo,coin->symbol,coin->chain->zcash,chain->auxpow,chain->hashalgo,0,&hash2,buf,(void *)&zmsg,sizeof(buf));
coin->chain->auxpow = auxback; chain->auxpow = auxback;
if ( coin->virtualchain == 0 && coin->MAXPEERS > 1 ) if ( coin->virtualchain == 0 && coin->MAXPEERS > 1 )
{ {
if ( coin->chain->debug == 0 && memcmp(hash2.bytes,chain->genesis_hashdata,sizeof(hash2)) != 0 ) if ( chain->debug == 0 && memcmp(hash2.bytes,chain->genesis_hashdata,sizeof(hash2)) != 0 )
{ {
bits256_str(str,hash2); bits256_str(str,hash2);
printf("genesis mismatch? zcash.%d calculated %s vs %s\n",coin->chain->zcash,str,bits256_str(str2,*(bits256 *)chain->genesis_hashdata)); printf("genesis mismatch? zcash.%d calculated %s vs %s\n",chain->zcash,str,bits256_str(str2,*(bits256 *)chain->genesis_hashdata));
memcpy(hash2.bytes,chain->genesis_hashdata,sizeof(hash2)); memcpy(hash2.bytes,chain->genesis_hashdata,sizeof(hash2));
} }
if ( coin->chain->debug != 0 ) if ( coin->chain->debug != 0 )
memcpy(hash2.bytes,chain->genesis_hashdata,sizeof(hash2)); memcpy(hash2.bytes,chain->genesis_hashdata,sizeof(hash2));
} else memcpy(hash2.bytes,chain->genesis_hashdata,sizeof(hash2)); } else memcpy(hash2.bytes,chain->genesis_hashdata,sizeof(hash2));
bits256_str(str,hash2); bits256_str(str,hash2);
printf("genesis.(%s) zcash.%d len.%d hash.%s\n",chain->genesis_hex,coin->chain->zcash,(int32_t)sizeof(zmsg.zH),str); if ( chain->debug != 0 )
iguana_blockconv(coin->chain->zcash,coin->chain->auxpow,(void *)block,&zmsg,hash2,0); printf("genesis.(%s) zcash.%d len.%d hash.%s\n",chain->genesis_hex,chain->zcash,(int32_t)sizeof(zmsg.zH),str);
iguana_blockconv(chain->zcash,chain->auxpow,(void *)block,&zmsg,hash2,0);
block->RO.txn_count = 1; block->RO.txn_count = 1;
block->RO.numvouts = 1; block->RO.numvouts = 1;
if ( coin->chain->zcash != 0 ) if ( chain->zcash != 0 )
block->RO.allocsize = sizeof(struct iguana_zblock); block->RO.allocsize = sizeof(struct iguana_zblock);
else block->RO.allocsize = (int32_t)sizeof(*block); else block->RO.allocsize = (int32_t)sizeof(*block);
iguana_gotdata(coin,0,0); iguana_gotdata(coin,0,0);
if ( (ptr= iguana_blockhashset("genesis0",coin,0,hash2,1)) != 0 ) if ( (ptr= iguana_blockhashset("genesis0",coin,0,hash2,1)) != 0 )
{ {
iguana_blockcopy(coin->chain->zcash,coin->chain->auxpow,coin,ptr,block); iguana_blockcopy(chain->zcash,chain->auxpow,coin,ptr,block);
iguana_blocksizecheck("genesis ptr",coin->chain->zcash,ptr); iguana_blocksizecheck("genesis ptr",chain->zcash,ptr);
ptr->mainchain = 1; ptr->mainchain = 1;
ptr->height = 0; ptr->height = 0;
//coin->blocks.RO[0] = block.RO; //coin->blocks.RO[0] = block.RO;
if ( coin->virtualchain != 0 || (height= iguana_chainextend(myinfo,coin,ptr)) == 0 ) if ( coin->virtualchain != 0 || (height= iguana_chainextend(myinfo,coin,ptr)) == 0 )
{ {
iguana_blockzcopy(coin->chain->zcash,block,ptr); iguana_blockzcopy(chain->zcash,block,ptr);
iguana_blockzcopy(coin->chain->zcash,(void *)&coin->blocks.hwmchain,ptr); iguana_blockzcopy(chain->zcash,(void *)&coin->blocks.hwmchain,ptr);
printf("size.%d genesis block PoW %f ptr %f\n",block->RO.allocsize,block->PoW,ptr->PoW); printf("size.%d genesis block PoW %f ptr %f\n",block->RO.allocsize,block->PoW,ptr->PoW);
coin->blocks.recvblocks = coin->blocks.issuedblocks = 1; coin->blocks.recvblocks = coin->blocks.issuedblocks = 1;
} else printf("genesis block doesnt validate for %s ht.%d\n",coin->symbol,height); } else printf("genesis block doesnt validate for %s ht.%d\n",coin->symbol,height);
@ -313,7 +314,7 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3
#ifndef IGUANA_DISABLEPEERS #ifndef IGUANA_DISABLEPEERS
addr = &coin->peers->active[m++]; addr = &coin->peers->active[m++];
iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(line)); iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(line));
printf("call initpeer.(%s)\n",addr->ipaddr); //printf("call initpeer.(%s)\n",addr->ipaddr);
iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD); iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD);
#endif #endif
} }

9
iguana/iguana_msg.c

@ -91,7 +91,7 @@ int32_t iguana_rwmerklebranch(int32_t rwflag,uint8_t *serialized,struct iguana_m
return(len); return(len);
} }
int32_t iguana_rwzsolution(int32_t rwflag,uint8_t *serialized,uint16_t *solution,int32_t n) int32_t iguana_rwzsolution(int32_t rwflag,uint8_t *serialized,uint8_t *solution,int32_t n)
{ {
int32_t i,len = 0; int32_t i,len = 0;
for (i=0; i<n; i++) for (i=0; i<n; i++)
@ -943,10 +943,11 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s
{ {
if ( coin->chain->debug != 0 ) if ( coin->chain->debug != 0 )
{ {
int32_t i; int32_t i,max;
for (i=0; i<recvlen && i<80; i++) max = coin->chain->zcash == 0 ? 80 : sizeof(struct iguana_msgzblockhdr);
for (i=0; i<max; i++)
printf("%02x",data[i]); printf("%02x",data[i]);
printf(" block.[%d]\n",recvlen); printf(" block.[%d]\n",max);
} }
addr->msgcounts.block++; addr->msgcounts.block++;
if ( (n= iguana_gentxarray(myinfo,coin,rawmem,&txdata,&len,data,recvlen)) == recvlen || n == recvlen-1 ) if ( (n= iguana_gentxarray(myinfo,coin,rawmem,&txdata,&len,data,recvlen)) == recvlen || n == recvlen-1 )

2
iguana/iguana_peers.c

@ -737,7 +737,7 @@ void iguana_startconnection(void *arg)
printf("avoid self-loopback\n"); printf("avoid self-loopback\n");
return; return;
} }
printf(">>>>>>>> startconnection.(%s) pending.%u usock.%d addrind.%d\n",addr->ipaddr,addr->pending,addr->usock,addr->addrind); //printf(">>>>>>>> startconnection.(%s) pending.%u usock.%d addrind.%d\n",addr->ipaddr,addr->pending,addr->usock,addr->addrind);
addr->pending = (uint32_t)time(NULL); addr->pending = (uint32_t)time(NULL);
if ( (port= (uint16_t)(addr->ipbits >> 32)) == 0 ) if ( (port= (uint16_t)(addr->ipbits >> 32)) == 0 )
port = coin->chain->portp2p; port = coin->chain->portp2p;

4
includes/iguana_structs.h

@ -116,7 +116,7 @@ struct iguana_msgzblockhdr
uint32_t timestamp,bits; uint32_t timestamp,bits;
bits256 bignonce; bits256 bignonce;
uint8_t var_numelements[3]; uint8_t var_numelements[3];
uint16_t solution[ZCASH_SOLUTION_ELEMENTS]; uint8_t solution[ZCASH_SOLUTION_ELEMENTS];
} PACKEDSTRUCT; } PACKEDSTRUCT;
/*int32_t nVersion; /*int32_t nVersion;
@ -205,7 +205,7 @@ struct iguana_blockRO
uint16_t txn_count,numvouts,numvins,allocsize; uint16_t txn_count,numvouts,numvins,allocsize;
}PACKEDSTRUCT; }PACKEDSTRUCT;
struct iguana_zcashRO { bits256 bignonce; uint32_t numelements; uint16_t solution[ZCASH_SOLUTION_ELEMENTS]; }PACKEDSTRUCT; struct iguana_zcashRO { bits256 bignonce; uint32_t numelements; uint8_t solution[ZCASH_SOLUTION_ELEMENTS]; } PACKEDSTRUCT;
struct iguana_zblockRO struct iguana_zblockRO
{ {

Loading…
Cancel
Save