Browse Source

Test

etomic
jl777 8 years ago
parent
commit
cbc557f2a4
  1. 2
      iguana/exchanges/LP_include.h
  2. 17
      iguana/exchanges/LP_socket.c
  3. 17
      iguana/exchanges/LP_utxos.c

2
iguana/exchanges/LP_include.h

@ -263,7 +263,7 @@ struct iguana_info
void *electrum; void *ctx; void *electrum; void *ctx;
uint64_t maxamount,kmd_equiv,balanceA,balanceB,valuesumA,valuesumB; uint64_t maxamount,kmd_equiv,balanceA,balanceB,valuesumA,valuesumB;
uint8_t pubkey33[33],zcash; uint8_t pubkey33[33],zcash;
bits256 lastprivkey; uint32_t lastprivkeytime; bits256 lastprivkey; uint32_t lastprivkeytime; int32_t privkeydepth;
bits256 cachedtxid; uint8_t *cachedtxiddata; int32_t cachedtxidlen; bits256 cachedtxid; uint8_t *cachedtxiddata; int32_t cachedtxidlen;
bits256 cachedmerkle; int32_t cachedmerkleheight; bits256 cachedmerkle; int32_t cachedmerkleheight;
}; };

17
iguana/exchanges/LP_socket.c

@ -423,19 +423,19 @@ cJSON *electrum_submit(char *symbol,struct electrum_info *ep,cJSON **retjsonp,ch
{ {
*retjsonp = 0; *retjsonp = 0;
sprintf(stratumreq,"{ \"jsonrpc\":\"2.0\", \"id\": %u, \"method\":\"%s\", \"params\": %s }\n",ep->stratumid,method,params); sprintf(stratumreq,"{ \"jsonrpc\":\"2.0\", \"id\": %u, \"method\":\"%s\", \"params\": %s }\n",ep->stratumid,method,params);
//printf("%s %s",symbol,stratumreq); printf("%s %s",symbol,stratumreq);
memset(ep->buf,0,ep->bufsize); memset(ep->buf,0,ep->bufsize);
sitem = electrum_sitem(ep,stratumreq,timeout,retjsonp); sitem = electrum_sitem(ep,stratumreq,timeout,retjsonp);
/*sitem = (struct stritem *)queueitem(stratumreq); /*sitem = (struct stritem *)queueitem(stratumreq);
sitem->expiration = timeout; sitem->expiration = timeout;
sitem->DL.type = ep->stratumid++; sitem->DL.type = ep->stratumid++;
sitem->retptrp = (void **)retjsonp;*/ sitem->retptrp = (void **)retjsonp;*/
portable_mutex_lock(&ep->mutex); //portable_mutex_lock(&ep->mutex);
//queue_enqueue("sendQ",&ep->sendQ,&sitem->DL); //queue_enqueue("sendQ",&ep->sendQ,&sitem->DL);
expiration = (uint32_t)time(NULL) + timeout + 1; expiration = (uint32_t)time(NULL) + timeout + 1;
while ( *retjsonp == 0 && time(NULL) <= expiration ) while ( *retjsonp == 0 && time(NULL) <= expiration )
usleep(5000); usleep(15000);
portable_mutex_unlock(&ep->mutex); //portable_mutex_unlock(&ep->mutex);
if ( *retjsonp == 0 || jobj(*retjsonp,"error") != 0 ) if ( *retjsonp == 0 || jobj(*retjsonp,"error") != 0 )
{ {
if ( ++ep->numerrors >= LP_ELECTRUM_MAXERRORS ) if ( ++ep->numerrors >= LP_ELECTRUM_MAXERRORS )
@ -897,15 +897,8 @@ int32_t LP_recvfunc(struct electrum_info *ep,char *str,int32_t len)
cJSON *strjson,*errjson,*resultjson,*paramsjson; char *method; int32_t i,n,height; uint32_t idnum=0; struct stritem *stritem; struct iguana_info *coin; struct queueitem *tmp,*item = 0; cJSON *strjson,*errjson,*resultjson,*paramsjson; char *method; int32_t i,n,height; uint32_t idnum=0; struct stritem *stritem; struct iguana_info *coin; struct queueitem *tmp,*item = 0;
if ( str == 0 || len == 0 ) if ( str == 0 || len == 0 )
return(-1); return(-1);
printf("RECV.(%s)\n",str);
ep->lasttime = (uint32_t)time(NULL); ep->lasttime = (uint32_t)time(NULL);
/*if ( (strjson= cJSON_Parse(str)) == 0 )
{
strjson = cJSON_CreateObject();
resitem = cJSON_CreateObject();
jaddstr(resitem,"string",str);
jadd(strjson,"result",resitem);
printf("mapped.(%s) -> %s\n",str,jprint(strjson,0));
}*/
if ( (strjson= cJSON_Parse(str)) != 0 ) if ( (strjson= cJSON_Parse(str)) != 0 )
{ {
resultjson = jobj(strjson,"result"); resultjson = jobj(strjson,"result");

17
iguana/exchanges/LP_utxos.c

@ -506,7 +506,10 @@ int32_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypri
return(0); return(0);
coin->lastprivkey = myprivkey; coin->lastprivkey = myprivkey;
coin->lastprivkeytime = (uint32_t)time(NULL); coin->lastprivkeytime = (uint32_t)time(NULL);
printf("privkey init.(%s) %s\n",coin->symbol,coin->smartaddr); if ( coin->privkeydepth > 0 )
return(0);
coin->privkeydepth++;
printf("privkey init.(%s) %s depth.%d\n",coin->symbol,coin->smartaddr,coin->privkeydepth);
if ( coin->inactive == 0 ) if ( coin->inactive == 0 )
LP_listunspent_issue(coin->symbol,coin->smartaddr,0); LP_listunspent_issue(coin->symbol,coin->smartaddr,0);
array = LP_listunspent(coin->symbol,coin->smartaddr); array = LP_listunspent(coin->symbol,coin->smartaddr);
@ -543,9 +546,9 @@ int32_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypri
height = jint(item,"height"); height = jint(item,"height");
} }
satoshis = LP_txvalue(destaddr,coin->symbol,txid,vout); satoshis = LP_txvalue(destaddr,coin->symbol,txid,vout);
//if ( satoshis != 0 && satoshis != value ) if ( satoshis != 0 && satoshis != value )
printf("%s %s privkey_init value %.8f vs %.8f (%s) %.8f %.8f\n",coin->symbol,coin->smartaddr,dstr(satoshis),dstr(value),jprint(item,0),jdouble(item,"amount"),jdouble(item,"interest")); printf("%s %s privkey_init value %.8f vs %.8f (%s) %.8f %.8f\n",coin->symbol,coin->smartaddr,dstr(satoshis),dstr(value),jprint(item,0),jdouble(item,"amount"),jdouble(item,"interest"));
if ( LP_inventory_prevent(iambob,coin->symbol,txid,vout) == 0 )//&& height > 0 ) if ( coin->electrum != 0 || LP_inventory_prevent(iambob,coin->symbol,txid,vout) == 0 )//&& height > 0 )
{ {
values[i] = satoshis; values[i] = satoshis;
//flag += LP_address_utxoadd(coin,destaddr,txid,vout,satoshis,height,-1); //flag += LP_address_utxoadd(coin,destaddr,txid,vout,satoshis,height,-1);
@ -554,9 +557,9 @@ int32_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypri
//printf("array.%d\n",n); //printf("array.%d\n",n);
while ( used < n-1 ) while ( used < n-1 )
{ {
for (i=0; i<n; i++) //for (i=0; i<n; i++)
printf("%.8f ",dstr(values[i])); // printf("%.8f ",dstr(values[i]));
printf("used.%d of n.%d\n",used,n); //printf("used.%d of n.%d\n",used,n);
if ( (i= LP_maxvalue(values,n)) >= 0 ) if ( (i= LP_maxvalue(values,n)) >= 0 )
{ {
item = jitem(array,i); item = jitem(array,i);
@ -642,6 +645,8 @@ int32_t LP_privkey_init(int32_t mypubsock,struct iguana_info *coin,bits256 mypri
} }
if ( values != 0 ) if ( values != 0 )
free(values); free(values);
if ( coin->privkeydepth > 0 )
coin->privkeydepth--;
//printf("privkey.%s %.8f\n",symbol,dstr(total)); //printf("privkey.%s %.8f\n",symbol,dstr(total));
return(flag); return(flag);
} }

Loading…
Cancel
Save