Browse Source

Test

etomic
jl777 7 years ago
parent
commit
f8edc96352
  1. 10
      iguana/exchanges/LP_commands.c
  2. 2
      iguana/exchanges/LP_nativeDEX.c
  3. 48
      iguana/exchanges/LP_stats.c

10
iguana/exchanges/LP_commands.c

@ -603,6 +603,8 @@ instantdex_claim()\n\
}
argjson = reqjson;
}
else if ( strcmp(method,"getdPoW") == 0 )
retstr = clonestr("{\"result\":\"success\"}");
}
else
{
@ -610,7 +612,13 @@ instantdex_claim()\n\
{
return(jprint(LP_tradesarray(base,rel,juint(argjson,"starttime"),juint(argjson,"endtime"),jint(argjson,"timescale")),1));
}
}
else if ( strcmp(method,"getdPoW") == 0 )
{
if ( (ptr= LP_coinfind(jstr(argjson,"coin"))) != 0 )
LP_dPoW_broadcast(ptr);
retstr = clonestr("{\"result\":\"success\"}");
}
}
// received response
if ( strcmp(method,"swapstatus") == 0 )
return(LP_swapstatus_recv(argjson));

2
iguana/exchanges/LP_nativeDEX.c

@ -646,7 +646,7 @@ void LP_coinsloop(void *_coins)
int32_t LP_mainloop_iter(void *ctx,char *myipaddr,struct LP_peerinfo *mypeer,int32_t pubsock,char *pushaddr,uint16_t myport)
{
static uint32_t counter;//,didinstantdex;
struct iguana_info *coin,*ctmp; char *origipaddr; uint32_t now; int32_t notarized,height,nonz = 0; bits256 zero; cJSON *reqjson;
struct iguana_info *coin,*ctmp; char *origipaddr; uint32_t now; int32_t notarized,height,nonz = 0;
if ( (origipaddr= myipaddr) == 0 )
origipaddr = "127.0.0.1";
if ( mypeer == 0 )

48
iguana/exchanges/LP_stats.c

@ -28,6 +28,17 @@ char *LP_stats_methods[] = { "unknown", "request", "reserved", "connect", "conne
static uint32_t LP_requests,LP_reserveds,LP_connects,LP_connecteds,LP_tradestatuses,LP_parse_errors,LP_unknowns,LP_duplicates,LP_aliceids;
void LP_dPoW_request(struct iguana_info *coin)
{
bits256 zero; cJSON *reqjson;
reqjson = cJSON_CreateObject();
jaddstr(reqjson,"method","getdPoW");
jaddstr(reqjson,"coin",coin->symbol);
memset(zero.bytes,0,sizeof(zero));
printf("request %s\n",jprint(reqjson,0));
LP_reserved_msg(0,coin->symbol,coin->symbol,zero,jprint(reqjson,1));
}
void LP_dPoW_broadcast(struct iguana_info *coin)
{
bits256 zero; cJSON *reqjson;
@ -40,6 +51,7 @@ void LP_dPoW_broadcast(struct iguana_info *coin)
jaddbits256(reqjson,"notarizedhash",coin->notarizedhash);
jaddbits256(reqjson,"notarizationtxid",coin->notarizationtxid);
memset(zero.bytes,0,sizeof(zero));
printf("broadcast %s\n",jprint(reqjson,0));
LP_reserved_msg(0,coin->symbol,coin->symbol,zero,jprint(reqjson,1));
}
}
@ -64,6 +76,25 @@ char *LP_dPoW_recv(cJSON *argjson)
return(clonestr("{\"result\":\"success\"}"));
}
int32_t LP_dPoWheight(struct iguana_info *coin) // get dPoW protected height
{
int32_t notarized,oldnotarized;
if ( coin->electrum == 0 )
{
coin->heighttime = (uint32_t)(time(NULL) - 61);
oldnotarized = coin->notarized;
LP_getheight(&notarized,coin);
if ( notarized != 0 && notarized != oldnotarized )
{
printf("dPoWheight.%s %d <- %d\n",coin->symbol,oldnotarized,notarized);
coin->notarized = notarized;
}
}
else if ( coin->notarized == 0 )
LP_dPoW_request(coin);
return(coin->notarized);
}
void LP_tradecommand_log(cJSON *argjson)
{
static FILE *logfp; char *jsonstr;
@ -260,23 +291,6 @@ int32_t LP_swapstats_update(struct LP_swapstats *sp,struct LP_quoteinfo *qp,cJSO
return(0);
}
int32_t LP_dPoWheight(struct iguana_info *coin) // get dPoW protected height
{
int32_t notarized,oldnotarized;
if ( coin->electrum == 0 )
{
coin->heighttime = (uint32_t)(time(NULL) - 61);
oldnotarized = coin->notarized;
LP_getheight(&notarized,coin);
if ( notarized != 0 && notarized != oldnotarized )
{
printf("dPoWheight.%s %d <- %d\n",coin->symbol,oldnotarized,notarized);
coin->notarized = notarized;
}
}
return(coin->notarized);
}
int32_t LP_finished_lastheight(struct LP_swapstats *sp)
{
int32_t height = 1; struct iguana_info *bob,*alice; //char str[65];

Loading…
Cancel
Save