Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
9f49ab3c4f
  1. 10
      iguana/iguana777.c
  2. 22
      iguana/iguana_exchanges.c
  3. 4
      iguana/iguana_msg.c
  4. 2
      iguana/iguana_recv.c
  5. 2
      iguana/main.c
  6. 2
      iguana/tests/decoderawtransaction
  7. 1
      iguana/tests/rate
  8. 1
      includes/iguana_apideclares.h

10
iguana/iguana777.c

@ -830,8 +830,8 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
}
if ( coin->startPEND > maxval*mult )
coin->startPEND = maxval*mult;
else if ( coin->startPEND < 1 )
coin->startPEND = 1;
else if ( coin->startPEND < 2 )
coin->startPEND = 2;
coin->MAXBUNDLES = coin->startPEND;
if ( (coin->endPEND= juint(json,"endpend")) == 0 )
{
@ -841,8 +841,8 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
}
if ( coin->endPEND > maxval*mult )
coin->endPEND = maxval*mult;
else if ( coin->endPEND < 1 )
coin->endPEND = 1;
else if ( coin->endPEND < 2 )
coin->endPEND = 2;
#ifdef __PNACL__
coin->startPEND = coin->endPEND = 1;
#endif
@ -859,7 +859,7 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
if ( coin->MAXMEM == 0 )
coin->MAXMEM = IGUANA_DEFAULTRAM;
coin->MAXMEM *= (1024L * 1024 * 1024);
coin->enableCACHE = (strcmp("BTCD",coin->symbol) == 0);
coin->enableCACHE = 0;//(strcmp("BTCD",coin->symbol) == 0);
if ( jobj(json,"cache") != 0 )
coin->enableCACHE = juint(json,"cache");
if ( (coin->polltimeout= juint(json,"poll")) <= 0 )

22
iguana/iguana_exchanges.c

@ -897,7 +897,7 @@ char *exchanges777_Qprices(struct exchange_info *exchange,char *base,char *rel,i
}
if ( base[0] == 0 || rel[0] == 0 || (polarity= (*exchange->issue.supports)(exchange,base,rel,argjson)) == 0 )
{
printf("%s invalid (%s) or (%s)\n",exchange->name,base,rel);
//printf("%s invalid (%s) or (%s)\n",exchange->name,base,rel);
return(clonestr("{\"error\":\"invalid base or rel\"}"));
}
if ( depth <= 0 )
@ -1304,6 +1304,26 @@ STRING_ARG(InstantDEX,allpairs,exchange)
else return(clonestr("{\"error\":\"cant find or create exchange\"}"));
}
TWO_STRINGS(iguana,rate,base,rel)
{
cJSON *retjson,*tmpjson; char *retstr,baserel[128],_base[64],_rel[64]; double aveprice = 0.;
safecopy(_base,base,sizeof(_base));
safecopy(_rel,rel,sizeof(_rel));
if ( (retstr= tradebot_aveprice(myinfo,coin,json,remoteaddr,"",_base,_rel,1)) != 0 )
{
if ( (tmpjson= cJSON_Parse(retstr)) != 0 )
{
aveprice = jdouble(tmpjson,"aveprice");
retjson = cJSON_CreateObject();
sprintf(baserel,"%s/%s",_base,_rel);
jaddnum(retjson,baserel,aveprice);
jaddstr(retjson,"result","success");
free_json(tmpjson);
return(jprint(retjson,1));
} else return(clonestr("{\"error\":\"error parsing return from aveprice\"}"));
} else return(clonestr("{\"error\":\"null return from aveprice\"}"));
}
INT_AND_ARRAY(iguana,rates,unused,quotes)
{
int32_t i,n,len,j; char *retstr,*quote,base[16][64],rel[16][64],field[64]; double aveprice; cJSON *tmpjson,*item,*array=0,*retjson = cJSON_CreateObject();

4
iguana/iguana_msg.c

@ -898,7 +898,7 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
{
struct iguana_msgblock msg; struct iguana_zblock *zblocks; uint32_t tmp,n=0;
len = 0;
if ( addr != 0 && recvlen >= sizeof(bits256) )
if ( addr != 0 && recvlen >= sizeof(bits256) && strcmp("BTCD",coin->symbol) != 0 )
{
if ( ishost == 0 )
{
@ -947,9 +947,11 @@ int32_t iguana_msgparser(struct iguana_info *coin,struct iguana_peer *addr,struc
} else printf("got unexpected n.%d for headers\n",n);
}
else if ( addr->headerserror == 0 )
{
len = iguana_peergetrequest(myinfo,coin,addr,data,recvlen,0);
}
}
}
else if ( (ishost= (strcmp(H->command,"version") == 0)) || strcmp(H->command,"verack") == 0 )
{
if ( addr != 0 )

2
iguana/iguana_recv.c

@ -373,7 +373,7 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
//iguana_blast(coin,addr);
}
}
copyflag = 0;//(coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0);
copyflag = (coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0);
bp = 0, bundlei = -2;
bp = iguana_bundlefind(coin,&bp,&bundlei,origtxdata->zblock.RO.hash2);
if ( bp != 0 && bundlei >= 0 && bundlei < bp->n )

2
iguana/main.c

@ -551,7 +551,7 @@ void iguana_appletests(struct supernet_info *myinfo)
bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33);
printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i);
getchar();**/
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":129,\"maxpeers\":16,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":1}"),0,myinfo->rpcport)) != 0 )
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":2,\"endpend\":2,\"services\":129,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":1}"),0,myinfo->rpcport)) != 0 )
{
free(str);
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":8,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 )

2
iguana/tests/decoderawtransaction

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"010000007668aa570150afe1c33378ea607b3d1e54414d37e05022e328bfc680aee5ea50d7d5015af8000000009147304402204ec3aa8eb10e8c06b589b95511b0ac2fb10068b4f203ed1a9f6a4fb87de63fa1022021306fbe65ccfecced1549e7587277a6281e2b19e1757ca45b7cd5e5f5bd1742014830450221008d0b2326153cef36de6b6479b917c5add86b399745ffb0952ba156564582674c02206f8feff3562e8691383236f6ad4e3ec2589cafaec9ab56ed9d8ab9cda4bd1dc501ffffffff01706f9800000000001976a91454a752f0d71b89d7c014ed0be29ca231c9546f9f88ac00000000\", 1]}"
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"01000000ab71aa5701b8b5b227160b1ddff8c851ef1750b4f73b8e24138b931d3befbf5d0b051c6cd200000000904730440220112c68dd9ac6b9f8d81c226b1cc72be7f4e75d9f81db82adf6931d23d45ccf360220266df0681e89fb3f603118a8f3764122eb2a131cbcc1d8cfa61351e1989adf0c0147304402203022147b0ae5135e413cd116db7310942f46bb91cc2dbebd30d814a09fe624d1022022725baa7aaea080c4c050da69bac4c70e7fb9b317190f51d7a3e263affe7d1801ffffffff01706f9800000000001976a91454a752f0d71b89d7c014ed0be29ca231c9546f9f88ac00000000\", 1]}"

1
iguana/tests/rate

@ -0,0 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"rate\",\"base\":\"BTCD\",\"rel\":\"BTC\"}"

1
includes/iguana_apideclares.h

@ -14,6 +14,7 @@
******************************************************************************/
INT_AND_ARRAY(iguana,rates,unused,quotes);
TWO_STRINGS(iguana,rate,base,rel);
ZERO_ARGS(InstantDEX,allcoins);
STRING_ARG(InstantDEX,available,source);

Loading…
Cancel
Save