Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
d5dd8d73f5
  1. 29
      iguana/iguana_instantdex.c
  2. 2
      iguana/iguana_stake.c
  3. 2
      iguana/main.c
  4. 2
      iguana/mini-gmp.c
  5. 8
      iguana/swaps/iguana_BTCswap.c

29
iguana/iguana_instantdex.c

@ -1377,8 +1377,8 @@ char *instantdex_parse(struct supernet_info *myinfo,struct instantdex_msghdr *ms
char *InstantDEX_hexmsg(struct supernet_info *myinfo,struct category_info *cat,void *ptr,int32_t len,char *remoteaddr)
{
struct instantdex_msghdr *msg = ptr; int32_t i,olen,slen,num,datalen,newlen,flag = 0;
uint8_t *serdata; struct supernet_info *myinfos[64]; struct instantdex_offer rawoffer;
struct instantdex_msghdr *msg = ptr; int32_t olen,slen,datalen,newlen,flag = 0;
uint8_t *serdata; struct instantdex_offer rawoffer; // struct supernet_info *myinfos[64];
uint64_t signerbits; uint8_t tmp[sizeof(msg->sig)]; char *retstr = 0;
bits256 orderhash,traderpub; cJSON *retjson,*item,*argjson = 0;
datalen = len - (int32_t)sizeof(msg->sig);
@ -1425,26 +1425,27 @@ char *InstantDEX_hexmsg(struct supernet_info *myinfo,struct category_info *cat,v
{
//printf("CALL instantdex_parse.(%s)\n",argjson!=0?jprint(argjson,0):"");
retjson = cJSON_CreateArray();
if ( (num= SuperNET_MYINFOS(myinfos,sizeof(myinfos)/sizeof(*myinfos))) == 0 )
/*if ( (num= SuperNET_MYINFOS(myinfos,sizeof(myinfos)/sizeof(*myinfos))) == 0 )
{
myinfos[0] = myinfo;
num = 1;
}
for (i=0; i<num; i++)
for (i=0; i<num; i++)*/
{
myinfo = myinfos[i];
//myinfo = myinfos[i];
//char str[65]; printf("i.%d of %d: %s\n",i,num,bits256_str(str,myinfo->myaddr.persistent));
traderpub = jbits256(argjson,"traderpub");
if ( bits256_cmp(traderpub,myinfo->myaddr.persistent) == 0 )
continue;
if ( (retstr= instantdex_parse(myinfo,msg,argjson,remoteaddr,signerbits,&rawoffer,orderhash,serdata,newlen)) != 0 )
if ( bits256_cmp(traderpub,myinfo->myaddr.persistent) != 0 )
{
item = cJSON_CreateObject();
jaddstr(item,"result",retstr);
if ( myinfo->handle[0] != 0 )
jaddstr(item,"handle",myinfo->handle);
jaddbits256(item,"traderpub",myinfo->myaddr.persistent);
jaddi(retjson,item);
if ( (retstr= instantdex_parse(myinfo,msg,argjson,remoteaddr,signerbits,&rawoffer,orderhash,serdata,newlen)) != 0 )
{
item = cJSON_CreateObject();
jaddstr(item,"result",retstr);
if ( myinfo->handle[0] != 0 )
jaddstr(item,"handle",myinfo->handle);
jaddbits256(item,"traderpub",myinfo->myaddr.persistent);
jaddi(retjson,item);
}
}
}
retstr = jprint(retjson,1);

2
iguana/iguana_stake.c

@ -85,7 +85,7 @@ uint32_t iguana_targetbits(struct iguana_info *coin,struct iguana_block *hwmchai
if ( (gap= prev->RO.timestamp - prev2->RO.timestamp) < 0 )
gap = NTARGETSPACING;
// ppcoin: target change every block, retarget with exponential moving toward target spacing
printf("MSPACING.%d gap.%d\n",NINTERVAL_MSPACING,gap);
//printf("MSPACING.%d gap.%d\n",NINTERVAL_MSPACING,gap);
targetval = mpz_muldivcmp(bits256_from_compact(prev->RO.bits),NINTERVAL_MSPACING + (gap << 1),NINTERVAL_PSPACING,targetval);
}
}

2
iguana/main.c

@ -306,7 +306,7 @@ char *SuperNET_processJSON(struct supernet_info *myinfo,cJSON *json,char *remote
timeout = IGUANA_JSONTIMEOUT;
if ( (method= jstr(json,"method")) != 0 && strcmp(method,"DHT") == 0 && remoteaddr != 0 && (hexmsg= jstr(json,"hexmsg")) != 0 )
{
//printf("hexmsgprocess\n");
printf("hexmsgprocess myinfo.%p\n",myinfo);
SuperNET_hexmsgprocess(myinfo,0,json,hexmsg,remoteaddr);
return(clonestr("{\"result\":\"processed remote DHT\"}"));
}

2
iguana/mini-gmp.c

@ -4425,7 +4425,7 @@ bits256 mpz_to_bits256(mpz_t bn)
bits256 mpz_muldivcmp(bits256 oldval,int32_t mulval,int32_t divval,bits256 targetval)
{
mpz_t bn,target; bits256 newval;
printf("mulval.%d divval.%d]\n",mulval,divval);
//printf("mulval.%d divval.%d]\n",mulval,divval);
mpz_init(bn), mpz_init(target);
mpz_from_bits256(bn,oldval);
mpz_mul_ui(bn,bn,mulval);

8
iguana/swaps/iguana_BTCswap.c

@ -1093,6 +1093,8 @@ char *instantdex_statemachine(struct instantdex_stateinfo *states,int32_t numsta
printf("%llu/%llu cmd.(%s) state.(%s) newlen.%d isbob.%d wait.%s have.%x myhave.%x myfee.%p\n",(long long)swap->mine.orderid,(long long)swap->other.orderid,cmdstr,swap->state->name,(int32_t)strlen(jprint(newjson,0)),instantdex_isbob(swap),swap->waitfortx,juint(argjson,"have"),swap->havestate,swap->myfee);
if ( jobj(argjson,"have") != 0 )
swap->otherhavestate |= juint(argjson,"have");
if ( jobj(argjson,"mychoosei") != 0 )
swap->otherchoosei |= juint(argjson,"mychoosei");
if ( swap->state->name[0] == 0 || (swap->expiration != 0 && time(NULL) > swap->expiration) )
{
swap->state = &states[state->timeoutind];
@ -1157,14 +1159,12 @@ char *instantdex_statemachine(struct instantdex_stateinfo *states,int32_t numsta
jaddstr(newjson,"feetx",swap->myfee->txbytes);
printf("add feetx to newjson have.%x\n",swap->havestate);
}
if ( swap->choosei >= 0 )
jaddnum(newjson,"mychoosei",swap->choosei);
if ( bits256_nonz(swap->pubAm) != 0 )
jaddbits256(newjson,"pubAm",swap->pubAm);
//if ( bits256_nonz(swap->privAm) != 0 )
// jaddbits256(newjson,"privAm",swap->privAm);
if ( bits256_nonz(swap->pubBn) != 0 )
jaddbits256(newjson,"pubBn",swap->pubBn);
//if ( bits256_nonz(swap->privBn) != 0 )
// jaddbits256(newjson,"privn",swap->privBn);
if ( instantdex_isbob(swap) == 0 )
{
if ( (swap->otherhavestate & INSTANTDEX_ORDERSTATE_HAVEALTPAYMENT) == 0 && swap->altpayment != 0 && jobj(newjson,"altpayment") == 0 )

Loading…
Cancel
Save