Browse Source

Merge pull request #412 from jl777/spvdex

Spvdex
etomic
jl777 7 years ago
committed by GitHub
parent
commit
fac17ea506
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      crypto777/OS_portable.c
  2. 4
      iguana/exchanges/LP_RTmetrics.c
  3. 4
      iguana/exchanges/LP_include.h
  4. 19
      iguana/exchanges/LP_nativeDEX.c
  5. 2
      iguana/exchanges/LP_network.c
  6. 6
      iguana/exchanges/LP_ordermatch.c
  7. 2
      iguana/exchanges/LP_prices.c
  8. 4
      iguana/exchanges/LP_scan.c
  9. 8
      iguana/exchanges/LP_swap.c
  10. 4
      iguana/exchanges/LP_transaction.c

4
crypto777/OS_portable.c

@ -249,13 +249,13 @@ void *OS_portable_tmpalloc(char *dirname,char *name,struct OS_memspace *mem,long
if ( mem->totalsize > origsize )
size = mem->totalsize;
else size = origsize;
fprintf(stderr,"filealloc.(%s) -> ",fname);
printf("filealloc.(%s) -> ",fname);
if ( OS_filealloc(&mem->M,fname,mem,size) == 0 )
{
printf("couldnt map tmpfile %s\n",fname);
return(0);
}
fprintf(stderr,"created\n");
printf("created\n");
}
ptr = iguana_memalloc(mem,origsize,1);
if ( mem->threadsafe != 0 )

4
iguana/exchanges/LP_RTmetrics.c

@ -259,10 +259,10 @@ cJSON *LP_RTmetrics_sort(char *base,char *rel,cJSON *rawasks,int32_t numasks,dou
item = jitem(rawasks,sortbuf[i].ind);
jaddi(array,jduplicate(item));
}
free(sortbuf);
for (; i<num; i++)
for (; i<numasks; i++)
jaddi(array,jduplicate(jitem(rawasks,i)));
printf("new ask order for %d of %d, capped at num.%d\n",groupi,numasks,num);
free(sortbuf);
} else array = rawasks;
return(array);
}

4
iguana/exchanges/LP_include.h

@ -35,10 +35,10 @@ void emscripten_usleep(int32_t x);
//#define LP_STRICTPEERS
#define LP_BARTERDEX_VERSION 0
#define LP_MAGICBITS 10
#define LP_MAGICBITS 8
#define LP_HTTP_TIMEOUT 3 // 1 is too small due to edge cases of time(NULL)
#define LP_AUTOTRADE_TIMEOUT 10
#define LP_AUTOTRADE_TIMEOUT 15
#define ELECTRUM_TIMEOUT 10
#define LP_ELECTRUM_MAXERRORS 3
#define LP_MEMPOOL_TIMEINCR 10

19
iguana/exchanges/LP_nativeDEX.c

@ -279,7 +279,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int
if ( (recvlen= nn_recv(sock,&ptr,NN_MSG,0)) > 0 )
{
methodstr[0] = 0;
if ( 0 )
if ( 1 )
{
#ifdef FROM_JS
printf("%s RECV.(%s)\n",typestr,(char *)ptr);
@ -289,7 +289,7 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int
{
if ( (mstr= jstr(recvjson,"method")) != 0 )//&& strcmp(mstr,"uitem") == 0 && (cstr= jstr(recvjson,"coin")) != 0 && strcmp(cstr,"REVS") == 0 )
{
printf("%s RECV.(%s)\n",typestr,(char *)ptr);
//printf("%s RECV.(%s)\n",typestr,(char *)ptr);
}
safecopy(methodstr,jstr(recvjson,"method"),sizeof(methodstr));
free_json(recvjson);
@ -300,8 +300,13 @@ int32_t LP_sock_check(char *typestr,void *ctx,char *myipaddr,int32_t pubsock,int
#endif
double millis = OS_milliseconds();
if ( strlen((char *)ptr)+sizeof(bits256) <= recvlen )
{
if ( LP_magic_check(ptr,recvlen,remoteaddr) <= 0 )
printf("magic check error\n");
{
//printf("magic check error\n");
}
recvlen -= sizeof(bits256);
}
if ( (retstr= LP_process_message(ctx,typestr,myipaddr,pubsock,ptr,recvlen,sock)) != 0 )
free(retstr);
if ( Broadcaststr != 0 )
@ -664,7 +669,7 @@ void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins)
int32_t i,n; cJSON *item;
for (i=0; i<sizeof(activecoins)/sizeof(*activecoins); i++)
{
fprintf(stderr,"%s ",activecoins[i]);
printf("%s ",activecoins[i]);
LP_coinfind(activecoins[i]);
LP_priceinfoadd(activecoins[i]);
}
@ -673,12 +678,12 @@ void LP_initcoins(void *ctx,int32_t pubsock,cJSON *coins)
for (i=0; i<n; i++)
{
item = jitem(coins,i);
fprintf(stderr,"%s ",jstr(item,"coin"));
printf("%s ",jstr(item,"coin"));
LP_coincreate(item);
LP_priceinfoadd(jstr(item,"coin"));
}
}
fprintf(stderr,"privkey updates\n");
printf("privkey updates\n");
}
void LP_initpeers(int32_t pubsock,struct LP_peerinfo *mypeer,char *myipaddr,uint16_t myport,char *seednode)
@ -1020,7 +1025,7 @@ void LPinit(uint16_t myport,uint16_t mypullport,uint16_t mypubport,uint16_t mybu
G.waiting = 1;
while ( G.initializing != 0 )
{
fprintf(stderr,".");
//fprintf(stderr,".");
sleep(3);
}
if ( LP_mainloop_iter(ctx,myipaddr,mypeer,pubsock,pushaddr,myport) != 0 )

2
iguana/exchanges/LP_network.c

@ -212,7 +212,7 @@ int32_t LP_magic_check(uint8_t *msg,int32_t recvlen,char *remoteaddr)
int32_t LP_crc32find(int32_t *duplicatep,int32_t ind,uint32_t crc32)
{
static uint32_t crcs[1024]; static unsigned long dup,total;
static uint32_t crcs[4096]; static unsigned long dup,total;
int32_t i;
*duplicatep = 0;
if ( ind < 0 )

6
iguana/exchanges/LP_ordermatch.c

@ -852,8 +852,8 @@ struct LP_utxoinfo *LP_buyutxo(double *ordermatchpricep,int64_t *bestsatoshisp,i
free(utxos);
if ( *ordermatchpricep == 0. || *bestdestsatoshisp == 0 )
return(0);
//int32_t changed;
//LP_mypriceset(&changed,autxo->coin,base,1. / *ordermatchpricep);
int32_t changed;
LP_mypriceset(&changed,autxo->coin,base,1. / *ordermatchpricep);
return(bestutxo);
}
@ -862,6 +862,8 @@ char *LP_autobuy(void *ctx,char *myipaddr,int32_t mypubsock,char *base,char *rel
uint64_t desttxfee,txfee; uint32_t lastnonce; int32_t i,maxiters,numpubs = 0; int64_t bestsatoshis=0,destsatoshis,bestdestsatoshis=0; struct iguana_info *basecoin,*relcoin; struct LP_utxoinfo *autxo,*bestutxo = 0; double qprice,ordermatchprice=0.; struct LP_quoteinfo Q; bits256 pubkeys[100];
basecoin = LP_coinfind(base);
relcoin = LP_coinfind(rel);
if ( gui == 0 )
gui = "nogui";
if ( basecoin == 0 || basecoin->inactive != 0 || relcoin == 0 || relcoin->inactive != 0 )
return(clonestr("{\"error\":\"base or rel not found or inactive\"}"));
if ( LP_aliceonly(base) > 0 )

2
iguana/exchanges/LP_prices.c

@ -1064,7 +1064,7 @@ void LP_pricefeedupdate(bits256 pubkey,char *base,char *rel,double price)
}
if ( (pubp= LP_pubkeyadd(pubkey)) != 0 )
{
//if ( (rand() % 100) == 0 )
if ( (rand() % 1000) == 0 )
printf("PRICEFEED UPDATE.(%-6s/%6s) %12.8f %s %12.8f\n",base,rel,price,bits256_str(str,pubkey),1./price);
pubp->timestamp = (uint32_t)time(NULL);
if ( fabs(pubp->matrix[basepp->ind][relpp->ind] - price) > SMALLVAL )

4
iguana/exchanges/LP_scan.c

@ -68,7 +68,7 @@ int32_t LP_scanblockchain(struct iguana_info *coin,int32_t startheight,int32_t e
}
n++;
if ( (n % 1000) == 0 )
fprintf(stderr,"%.1f%% ",100. * (double)n/(endheight-startheight+1));
printf("%.1f%% ",100. * (double)n/(endheight-startheight+1));
}
return(endheight);
}
@ -100,7 +100,7 @@ int32_t komodo_bannedset(int32_t *indallvoutsp,bits256 *array,int32_t max)
int32_t i;
if ( sizeof(banned_txids)/sizeof(*banned_txids) > max )
{
fprintf(stderr,"komodo_bannedset: buffer too small %ld vs %d\n",(long)sizeof(banned_txids)/sizeof(*banned_txids),max);
printf("komodo_bannedset: buffer too small %ld vs %d\n",(long)sizeof(banned_txids)/sizeof(*banned_txids),max);
exit(-1);
}
for (i=0; i<sizeof(banned_txids)/sizeof(*banned_txids); i++)

8
iguana/exchanges/LP_swap.c

@ -747,7 +747,7 @@ void LP_bobloop(void *_swap)
{
uint8_t *data; int32_t maxlen,m,n; uint32_t expiration; struct basilisk_swap *swap = _swap;
G.LP_pendingswaps++;
fprintf(stderr,"start swap iambob\n");
printf("start swap iambob\n");
maxlen = 1024*1024 + sizeof(*swap);
data = malloc(maxlen);
expiration = (uint32_t)time(NULL) + LP_SWAPSTEP_TIMEOUT;
@ -817,7 +817,7 @@ void LP_aliceloop(void *_swap)
expiration = (uint32_t)time(NULL) + LP_SWAPSTEP_TIMEOUT;
if ( swap != 0 )
{
fprintf(stderr,"start swap iamalice pair.%d\n",swap->N.pair);
printf("start swap iamalice pair.%d\n",swap->N.pair);
if ( LP_sendwait("pubkeys",60,swap->N.pair,swap,data,maxlen,LP_pubkeys_verify,LP_pubkeys_data) < 0 )
printf("error LP_sendwait pubkeys\n");
else if ( LP_sendwait("choosei",LP_SWAPSTEP_TIMEOUT,swap->N.pair,swap,data,maxlen,LP_choosei_verify,LP_choosei_data) < 0 )
@ -910,12 +910,12 @@ int32_t instantdex_pubkeyargs(struct basilisk_swap *swap,int32_t numpubs,bits256
{
if ( swap->I.numpubs+2 >= numpubs )
return(numpubs);
//fprintf(stderr,">>>>>> start generating %s\n",buf);
//printf(">>>>>> start generating %s\n",buf);
}
for (i=n=m=0; i<numpubs*100 && n<numpubs; i++)
{
pubi = instantdex_derivekeypair(swap->ctx,&privkey,pubkey,privkey,hash);
//fprintf(stderr,"i.%d n.%d numpubs.%d %02x vs %02x\n",i,n,numpubs,pubkey[0],firstbyte);
//printf("i.%d n.%d numpubs.%d %02x vs %02x\n",i,n,numpubs,pubkey[0],firstbyte);
if ( pubkey[0] != firstbyte )
continue;
if ( n < 2 )

4
iguana/exchanges/LP_transaction.c

@ -490,7 +490,7 @@ int32_t iguana_signrawtransaction(void *ctx,char *symbol,uint8_t wiftaddr,uint8_
if ( (txobj= bitcoin_hex2json(taddr,pubtype,p2shtype,isPoS,height,&txid,msgtx,rawtx,extraspace,extralen,serialized4,vins,V->suppress_pubkeys,zcash)) != 0 )
{
//printf("back from bitcoin_hex2json (%s)\n",jprint(vins,0));
} else fprintf(stderr,"no txobj from bitcoin_hex2json\n");
} else printf("no txobj from bitcoin_hex2json\n");
//printf("call hex2json.(%s) vins.(%s)\n",rawtx,jprint(vins,0));
if ( (numinputs= cJSON_GetArraySize(vins)) > 0 )
{
@ -593,7 +593,7 @@ int32_t iguana_signrawtransaction(void *ctx,char *symbol,uint8_t wiftaddr,uint8_
} else printf("interpreter passed\n");*/
} else printf("complete.%d\n",complete);
} else printf("rwmsgtx error\n");
} else fprintf(stderr,"no inputs in vins.(%s)\n",vins!=0?jprint(vins,0):"null");
} else printf("no inputs in vins.(%s)\n",vins!=0?jprint(vins,0):"null");
free(extraspace);
free(serialized), free(serialized2), free(serialized3), free(serialized4);
} else return(-1);

Loading…
Cancel
Save