Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
561b00c34b
  1. 6
      iguana/iguana777.h
  2. 11
      iguana/iguana_peers.c
  3. 2
      iguana/iguana_realtime.c
  4. 5
      iguana/iguana_recv.c
  5. 60
      iguana/iguana_txidfind.c

6
iguana/iguana777.h

@ -485,6 +485,8 @@ struct iguana_wallet { UT_hash_handle hh; struct iguana_waccount *wacct; };
struct scriptinfo { UT_hash_handle hh; uint32_t fpos; uint16_t scriptlen; uint8_t script[]; }; struct scriptinfo { UT_hash_handle hh; uint32_t fpos; uint16_t scriptlen; uint8_t script[]; };
struct hhbits256 { UT_hash_handle hh; bits256 txid; int32_t height; uint16_t firstvout; }; struct hhbits256 { UT_hash_handle hh; bits256 txid; int32_t height; uint16_t firstvout; };
struct iguana_monitorinfo { bits256 txid; int32_t numreported; uint8_t peerbits[IGUANA_MAXPEERS >> 3]; };
struct iguana_info struct iguana_info
{ {
char name[64],symbol[8],statusstr[512],scriptsfname[2][512]; char name[64],symbol[8],statusstr[512],scriptsfname[2][512];
@ -521,6 +523,7 @@ struct iguana_info
struct iguana_blocks blocks; bits256 APIblockhash,APItxid; char *APIblockstr; struct iguana_blocks blocks; bits256 APIblockhash,APItxid; char *APIblockstr;
struct iguana_hhutxo *utxotable; struct iguana_hhaccount *accountstable; char lastdispstr[2048]; struct iguana_hhutxo *utxotable; struct iguana_hhaccount *accountstable; char lastdispstr[2048];
double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num; double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num;
struct iguana_monitorinfo monitoring[256];
}; };
struct vin_signer { bits256 privkey; char coinaddr[64]; uint8_t siglen,sig[80],rmd160[20],pubkey[66]; }; struct vin_signer { bits256 privkey; char coinaddr[64]; uint8_t siglen,sig[80],rmd160[20],pubkey[66]; };
@ -994,7 +997,8 @@ bits256 iguana_calcblockhash(int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *se
uint32_t iguana_targetbits(struct iguana_info *coin,struct iguana_block *hwmchain,struct iguana_block *prev,struct iguana_block *prev2,int32_t PoSflag); uint32_t iguana_targetbits(struct iguana_info *coin,struct iguana_block *hwmchain,struct iguana_block *prev,struct iguana_block *prev2,int32_t PoSflag);
struct bitcoin_eventitem *instantdex_event(char *cmdstr,cJSON *argjson,cJSON *newjson,uint8_t *serdata,int32_t serdatalen); struct bitcoin_eventitem *instantdex_event(char *cmdstr,cJSON *argjson,cJSON *newjson,uint8_t *serdata,int32_t serdatalen);
void instantdex_eventfree(struct bitcoin_eventitem *ptr); void instantdex_eventfree(struct bitcoin_eventitem *ptr);
void iguana_txidmonitor(struct iguana_info *coin,bits256 txid); struct iguana_monitorinfo *iguana_txidmonitor(struct iguana_info *coin,bits256 txid);
struct iguana_monitorinfo *iguana_txidreport(struct iguana_info *coin,bits256 txid,struct iguana_peer *addr);
double iguana_txidstatus(struct iguana_info *coin,bits256 txid); double iguana_txidstatus(struct iguana_info *coin,bits256 txid);
extern int32_t HDRnet,netBLOCKS; extern int32_t HDRnet,netBLOCKS;

11
iguana/iguana_peers.c

@ -819,8 +819,12 @@ uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr)
return((uint32_t)time(NULL)); return((uint32_t)time(NULL));
if ( strncmp("0.0.0",ipaddr,5) != 0 && strcmp("0.0.255.255",ipaddr) != 0 && strcmp("1.0.0.0",ipaddr) != 0 ) if ( strncmp("0.0.0",ipaddr,5) != 0 && strcmp("0.0.255.255",ipaddr) != 0 && strcmp("1.0.0.0",ipaddr) != 0 )
{ {
if ( ipaddr[strlen(ipaddr)-1] == ':' ) for (i=0; ipaddr[i]!=0; i++)
ipaddr[strlen(ipaddr)-1] = 0; if ( ipaddr[i] == ':' )
{
ipaddr[i] = 0;
break;
}
if ( (ipbits= calc_ipbits(ipaddr)) != 0 ) if ( (ipbits= calc_ipbits(ipaddr)) != 0 )
{ {
expand_ipbits(checkaddr,ipbits); expand_ipbits(checkaddr,ipbits);
@ -840,7 +844,8 @@ uint32_t iguana_possible_peer(struct iguana_info *coin,char *ipaddr)
} else printf("ignore.(%s) lastconnect.%u lastkilled.%u numconnects.%d\n",ipaddr,iA->lastconnect,iA->lastkilled,iA->numconnects); } else printf("ignore.(%s) lastconnect.%u lastkilled.%u numconnects.%d\n",ipaddr,iA->lastconnect,iA->lastkilled,iA->numconnects);
} //else printf("skip.(%s) ind.%d status.%d\n",ipaddr,iA->hh.itemind,iA->status); } //else printf("skip.(%s) ind.%d status.%d\n",ipaddr,iA->hh.itemind,iA->status);
} else printf("cant find (%s) which should have been created\n",ipaddr); } else printf("cant find (%s) which should have been created\n",ipaddr);
} else printf("reject ipaddr.(%s) vs checkaddr.(%s)\n",ipaddr,checkaddr); }
else printf("reject ipaddr.(%s) vs checkaddr.(%s)\n",ipaddr,checkaddr);
} }
} }
free_queueitem(ipaddr); free_queueitem(ipaddr);

2
iguana/iguana_realtime.c

@ -193,7 +193,7 @@ void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp)
printf("balancegen error\n"); printf("balancegen error\n");
coin->RTdatabad = 1; coin->RTdatabad = 1;
} }
else if ( coin->RTgenesis == 0 && coin->firstRTgenesis == 0 ) else if ( coin->RTgenesis == 0 )//&& coin->firstRTgenesis == 0 )
coin->firstRTgenesis++, printf(">>>>>> IGUANA %s READY FOR REALTIME RPC <<<<<<\n",coin->symbol); coin->firstRTgenesis++, printf(">>>>>> IGUANA %s READY FOR REALTIME RPC <<<<<<\n",coin->symbol);
//printf("iguana_balancegen [%d] (%d to %d)\n",bp->hdrsi,coin->RTstarti,(coin->RTheight-1)%bp->n); //printf("iguana_balancegen [%d] (%d to %d)\n",bp->hdrsi,coin->RTstarti,(coin->RTheight-1)%bp->n);
coin->RTstarti = (coin->RTheight % bp->n); coin->RTstarti = (coin->RTheight % bp->n);

5
iguana/iguana_recv.c

@ -1095,10 +1095,11 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana
struct iguana_bundlereq *iguana_recvtxids(struct iguana_info *coin,struct iguana_bundlereq *req,bits256 *txids,int32_t n) struct iguana_bundlereq *iguana_recvtxids(struct iguana_info *coin,struct iguana_bundlereq *req,bits256 *txids,int32_t n)
{ {
char str[65]; int32_t i;
if ( n > 0 ) if ( n > 0 )
{ {
printf("got txids[%d] %s\n",n,bits256_str(str,txids[0])); for (i=0; i<n; i++)
iguana_txidreport(coin,txids[i],req->addr);
} }
return(req); return(req);
} }

60
iguana/iguana_txidfind.c

@ -605,12 +605,66 @@ int64_t iguana_fastfindcreate(struct iguana_info *coin)
return(total); return(total);
} }
void iguana_txidmonitor(struct iguana_info *coin,bits256 txid) struct iguana_monitorinfo *iguana_monitorfind(struct iguana_info *coin,bits256 txid)
{ {
int32_t i;
for (i=0; i<sizeof(coin->monitoring)/sizeof(*coin->monitoring); i++)
if ( bits256_cmp(coin->monitoring[i].txid,txid) == 0 )
return(&coin->monitoring[i]);
return(0);
}
struct iguana_monitorinfo *iguana_txidreport(struct iguana_info *coin,bits256 txid,struct iguana_peer *addr)
{
struct iguana_monitorinfo *ptr; char str[65];
if ( (ptr= iguana_monitorfind(coin,txid)) != 0 )
{
if ( GETBIT(ptr->peerbits,addr->addrind) == 0 )
{
char str[65]; printf("%s reports %s\n",addr->ipaddr,bits256_str(str,txid));
SETBIT(ptr->peerbits,addr->addrind);
ptr->numreported++;
}
} else printf("txid.%s not being monitored\n",bits256_str(str,txid));
return(0);
}
struct iguana_monitorinfo *iguana_txidmonitor(struct iguana_info *coin,bits256 txid)
{
int32_t i; struct iguana_monitorinfo *ptr;
if ( (ptr= iguana_monitorfind(coin,txid)) == 0 )
{
for (i=0; i<sizeof(coin->monitoring)/sizeof(*coin->monitoring); i++)
if ( bits256_nonz(coin->monitoring[i].txid) == 0 )
{
memset(&coin->monitoring[i],0,sizeof(coin->monitoring[i]));
coin->monitoring[i].txid = txid;
return(ptr);
}
}
printf("no monitoring slots left\n");
return(0);
} }
double iguana_txidstatus(struct iguana_info *coin,bits256 txid) double iguana_txidstatus(struct iguana_info *coin,bits256 txid)
{ {
int32_t height,firstvout,numranked; struct iguana_monitorinfo *ptr; char str[65];
if ( coin != 0 && (numranked= coin->peers.numranked) > 0 )
{
if ( (firstvout= iguana_unspentindfind(coin,0,0,0,0,&height,txid,0,coin->bundlescount-1)) != 0 )
{
if ( (ptr= iguana_monitorfind(coin,txid)) != 0 )
memset(ptr,0,sizeof(*ptr));
return((double)coin->longestchain - height);
}
if ( (ptr= iguana_monitorfind(coin,txid)) != 0 )
return((double)ptr->numreported / numranked);
else
{
printf("iguana_txidstatus: unexpected missing %s %s\n",coin->symbol,bits256_str(str,txid));
iguana_txidmonitor(coin,txid);
}
}
return(0.); return(0.);
} }

Loading…
Cancel
Save