Browse Source

Merge pull request #667 from jl777/jl777

getinfo to getblockchaininfo on error
patch-3
jl777 7 years ago
committed by GitHub
parent
commit
a40e3374f8
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      basilisk/basilisk_bitcoin.c
  2. 25
      iguana/dpow/dpow_rpc.c
  3. 2
      iguana/exchanges/coins
  4. 2
      iguana/kmd_lookup.h
  5. 16
      iguana/main.c
  6. 2
      includes/iguana_structs.h

4
basilisk/basilisk_bitcoin.c

@ -26,7 +26,7 @@ char *bitcoin_balance(struct iguana_info *coin,char *coinaddr,int32_t lastheight
{ {
int32_t i,n,height,maxconf=1<<30; int64_t balance = 0; char params[512],*curlstr; cJSON *array,*retjson,*curljson; int32_t i,n,height,maxconf=1<<30; int64_t balance = 0; char params[512],*curlstr; cJSON *array,*retjson,*curljson;
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
if ( (curlstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getinfo",params)) != 0 ) if ( (curlstr= bitcoind_getinfo(coin->symbol,coin->chain->serverport,coin->chain->userpass,coin->getinfostr)) != 0 )
{ {
if ( (curljson= cJSON_Parse(curlstr)) != 0 ) if ( (curljson= cJSON_Parse(curlstr)) != 0 )
{ {
@ -181,7 +181,7 @@ int32_t basilisk_bitcoinscan(struct iguana_info *coin,uint8_t origblockspace[IGU
{ {
struct iguana_txblock txdata; struct iguana_block B; int32_t len,starti,h,num=0,loadheight,hexlen,datalen,n,i,numtxids,flag=0,j,height=-1; cJSON *curljson,*blockjson,*txids; char *bitstr,*curlstr,params[128],str[65]; struct iguana_msghdr H; struct iguana_msgblock *msg; uint8_t *blockspace,revbits[4],bitsbuf[4]; bits256 hash2,checkhash2; struct iguana_txblock txdata; struct iguana_block B; int32_t len,starti,h,num=0,loadheight,hexlen,datalen,n,i,numtxids,flag=0,j,height=-1; cJSON *curljson,*blockjson,*txids; char *bitstr,*curlstr,params[128],str[65]; struct iguana_msghdr H; struct iguana_msgblock *msg; uint8_t *blockspace,revbits[4],bitsbuf[4]; bits256 hash2,checkhash2;
strcpy(params,"[]"); strcpy(params,"[]");
if ( (curlstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getinfo",params)) != 0 ) if ( (curlstr= bitcoind_getinfo(coin->symbol,coin->chain->serverport,coin->chain->userpass,coin->getinfostr)) != 0 )
{ {
if ( (curljson= cJSON_Parse(curlstr)) != 0 ) if ( (curljson= cJSON_Parse(curlstr)) != 0 )
{ {

25
iguana/dpow/dpow_rpc.c

@ -15,13 +15,34 @@
#define issue_curl(cmdstr) bitcoind_RPC(0,"curl",cmdstr,0,0,0,0) #define issue_curl(cmdstr) bitcoind_RPC(0,"curl",cmdstr,0,0,0,0)
char *bitcoind_getinfo(char *symbol,char *serverport,char *userpass,char *getinfostr)
{
char buf[1],*retstr; cJSON *retjson;
buf[0] = 0;
if ( getinfostr[0] == 0 )
strcpy(getinfostr,"getinfo");
retstr = bitcoind_passthru(symbol,serverport,userpass,getinfostr,buf);
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( jobj(retjson,"error") != 0 && strcmp(getinfostr,"getinfo") == 0 )
{
strcpy(getinfostr,"getblockchaininfo");
free(retstr);
retstr = bitcoind_passthru(symbol,serverport,userpass,getinfostr,buf);
printf("switch to getblockchaininfo -> (%s)\n",retstr);
}
free(retjson);
}
return(retstr);
}
cJSON *dpow_getinfo(struct supernet_info *myinfo,struct iguana_info *coin) cJSON *dpow_getinfo(struct supernet_info *myinfo,struct iguana_info *coin)
{ {
char buf[128],*retstr=0; cJSON *json = 0; char buf[128],*retstr=0; cJSON *json = 0;
if ( coin->FULLNODE < 0 ) if ( coin->FULLNODE < 0 )
{ {
buf[0] = 0; buf[0] = 0;
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getinfo",buf); retstr = bitcoind_getinfo(coin->symbol,coin->chain->serverport,coin->chain->userpass,coin->getinfostr);
usleep(10000); usleep(10000);
} }
else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 )
@ -1244,7 +1265,7 @@ int32_t dpow_issuer_iteration(struct dpow_info *dp,struct iguana_info *coin,int3
if ( height <= 0 ) if ( height <= 0 )
height = 1; height = 1;
*isrealtimep = 0; *isrealtimep = 0;
if ( (retstr= dpow_issuemethod(coin->chain->userpass,(char *)"getinfo",0,port)) != 0 ) if ( (retstr= dpow_issuemethod(coin->chain->userpass,(char *)coin->getinfostr,0,port)) != 0 )
{ {
if ( (infoobj= cJSON_Parse(retstr)) != 0 ) if ( (infoobj= cJSON_Parse(retstr)) != 0 )
{ {

2
iguana/exchanges/coins

File diff suppressed because one or more lines are too long

2
iguana/kmd_lookup.h

@ -354,7 +354,7 @@ int32_t kmd_height(struct iguana_info *coin)
{ {
char params[64],*curlstr; cJSON *curljson; int32_t height = 0; char params[64],*curlstr; cJSON *curljson; int32_t height = 0;
strcpy(params,"[]"); strcpy(params,"[]");
if ( (curlstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getinfo",params)) != 0 ) if ( (curlstr= bitcoind_getinfo(coin->symbol,coin->chain->serverport,coin->chain->userpass,coin->getinfostr)) != 0 )
{ {
if ( (curljson= cJSON_Parse(curlstr)) != 0 ) if ( (curljson= cJSON_Parse(curlstr)) != 0 )
{ {

16
iguana/main.c

@ -2207,18 +2207,24 @@ void iguana_main(void *arg)
iguana_notarystats(totals,1); iguana_notarystats(totals,1);
exit(0); exit(0);
} }
else if ( strcmp((char *)arg,"notary") == 0 ) else if ( strncmp((char *)arg,"-port=",6) == 0 )
{
myinfo->rpcport = atoi(&((char *)arg)[6]);
printf("OVERRIDE IGUANA port <- %u\n",myinfo->rpcport);
}
else if ( strcmp((char *)arg,"notary") == 0 ) // must be second to last
{ {
myinfo->rpcport = IGUANA_NOTARYPORT; myinfo->rpcport = IGUANA_NOTARYPORT;
myinfo->IAMNOTARY = 1; myinfo->IAMNOTARY = 1;
myinfo->DEXEXPLORER = 0;//1; disable as SPV is used now myinfo->DEXEXPLORER = 0;//1; disable as SPV is used now
} }
else if ( strncmp((char *)arg,"-port=",6) == 0 ) else
{ {
myinfo->rpcport = atoi(&((char *)arg)[6]); myinfo->rpcport = IGUANA_NOTARYPORT;
printf("OVERRIDE IGUANA port <- %u\n",myinfo->rpcport); myinfo->IAMNOTARY = 1;
myinfo->DEXEXPLORER = 0;//1; disable as SPV is used now
elected = (char *)arg;
} }
else elected = (char *)arg;
} }
if ( komodo_initjson(elected) < 0 ) if ( komodo_initjson(elected) < 0 )
{ {

2
includes/iguana_structs.h

@ -528,7 +528,7 @@ struct iguana_info
#ifdef DEPRECATED_HHUTXO #ifdef DEPRECATED_HHUTXO
struct iguana_hhaccount *accountstable; struct iguana_hhaccount *accountstable;
#endif #endif
char lastdispstr[2048]; char lastdispstr[2048],getinfostr[64];
double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num; double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num;
struct iguana_monitorinfo monitoring[256]; struct iguana_monitorinfo monitoring[256];
int32_t notarychain,didaddresses; int32_t notarychain,didaddresses;

Loading…
Cancel
Save