jl777 8 years ago
parent
commit
2a2a4f50ae
  1. 7
      iguana/iguana_rpc.c
  2. 32
      iguana/main.c
  3. 1
      includes/iguana_funcs.h

7
iguana/iguana_rpc.c

@ -708,7 +708,7 @@ struct iguana_info *iguana_coinchoose(struct supernet_info *myinfo,char *symbol,
char *iguana_bitcoinRPC(struct supernet_info *myinfo,char *method,cJSON *json,char *remoteaddr,uint16_t port)
{
cJSON *params[16],*array; struct iguana_info *coin = 0; char symbol[16]; int32_t i,n; char *retstr = 0;
cJSON *params[16],*array; struct iguana_info *coin = 0; char symbol[16]; uint32_t immed; int32_t i,n; char *retstr = 0;
symbol[0] = 0;
memset(params,0,sizeof(params));
//printf("bitcoinRPC\n");
@ -722,6 +722,11 @@ char *iguana_bitcoinRPC(struct supernet_info *myinfo,char *method,cJSON *json,ch
//printf("method.(%s) (%s) remote.(%s) symbol.(%s)\n",method,jprint(json,0),remoteaddr,symbol);
if ( method != 0 && symbol[0] != 0 && (coin != 0 || (coin= iguana_coinfind(symbol)) != 0) )
{
if ( (immed= juint(json,"immediate")) != 0 )
{
if ( iguana_immediate(coin,immed) == 0 )
return(clonestr("{\"error\":\"coin is busy processing\"}"));
}
if ( (array= jarray(&n,json,"params")) == 0 )
{
i = 0, n = 0;

32
iguana/main.c

@ -251,9 +251,26 @@ char *iguana_blockingjsonstr(struct supernet_info *myinfo,struct iguana_info *co
return(clonestr("{\"error\":\"iguana jsonstr expired\"}"));
}
int32_t iguana_immediate(struct iguana_info *coin,int32_t immedmillis)
{
double endmillis;
if ( immedmillis > 60000 )
immedmillis = 60000;
endmillis = OS_milliseconds() + immedmillis;
while ( 1 )
{
if ( coin->busy_processing == 0 )
break;
usleep(100);
if ( OS_milliseconds() > endmillis )
break;
}
return(coin->busy_processing == 0);
}
char *SuperNET_processJSON(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *json,char *remoteaddr,uint16_t port)
{
cJSON *retjson; double endmillis; uint64_t tag; uint32_t timeout,immedmillis; char *jsonstr,*retjsonstr,*retstr = 0; //*hexmsg,*method,
cJSON *retjson; uint64_t tag; uint32_t timeout,immedmillis; char *jsonstr,*retjsonstr,*retstr = 0; //*hexmsg,*method,
//char str[65]; printf("processJSON %p %s\n",&myinfo->privkey,bits256_str(str,myinfo->privkey));
if ( json != 0 )
{
@ -276,18 +293,7 @@ char *SuperNET_processJSON(struct supernet_info *myinfo,struct iguana_info *coin
{
if ( coin != 0 )
{
if ( immedmillis > 60000 )
immedmillis = 60000;
endmillis = OS_milliseconds() + immedmillis;
while ( 1 )
{
if ( coin->busy_processing == 0 )
break;
usleep(100);
if ( OS_milliseconds() > endmillis )
break;
}
if ( coin->busy_processing == 0 )
if ( iguana_immediate(coin,immedmillis) != 0 )
retjsonstr = SuperNET_jsonstr(myinfo,jsonstr,remoteaddr,port);
else retjsonstr = clonestr("{\"error\":\"coin is busy processing\"}");
} else retjsonstr = SuperNET_jsonstr(myinfo,jsonstr,remoteaddr,port);

1
includes/iguana_funcs.h

@ -451,6 +451,7 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc
void iguana_utxoaddrs_purge(struct iguana_info *coin);
int32_t iguana_utxoupdate(struct iguana_info *coin,int16_t spent_hdrsi,uint32_t spent_unspentind,uint32_t spent_pkind,uint64_t spent_value,uint32_t spendind,uint32_t fromheight,uint8_t *rmd160);
int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *totalp,struct iguana_outpoint *unspents,int32_t max,uint64_t required,int32_t minconf,cJSON *addresses,char *remoteaddr);
int32_t iguana_immediate(struct iguana_info *coin,int32_t immedmillis);
int32_t iguana_fastfindreset(struct iguana_info *coin);
int64_t iguana_unspentset(struct supernet_info *myinfo,struct iguana_info *coin);
int32_t iguana_txidfastfind(struct iguana_info *coin,int32_t *heightp,bits256 txid,int32_t lasthdrsi);

Loading…
Cancel
Save