Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
26506f8c35
  1. 43
      iguana/iguana_instantdex.c
  2. 4
      iguana/main.c

43
iguana/iguana_instantdex.c

@ -109,27 +109,39 @@ struct instantdex_stateinfo *instantdex_statefind(struct instantdex_stateinfo *s
return(0);
}
void instantdex_stateinit(struct instantdex_stateinfo *states,int32_t numstates,struct instantdex_stateinfo *state,char *name,char *errorstr,char *timeoutstr,void *process_func,void *timeout_func)
{
struct instantdex_stateinfo *timeoutstate,*errorstate;
memset(state,0,sizeof(*state));
strcpy(state->name,name);
if ( (errorstate= instantdex_statefind(states,numstates,errorstr)) == 0 )
errorstate = &instantdex_errorstate;
state->errorevent = errorstate;
if ( (timeoutstate= instantdex_statefind(states,numstates,timeoutstr)) == 0 )
timeoutstate = &instantdex_timeoutstate;
state->timeoutevent = timeoutstate;
if ( (state->process= process_func) == 0 )
state->process = instantdex_defaultprocess;
if ( (state->timeout= timeout_func) == 0 )
state->timeout = instantdex_defaulttimeout;
}
struct instantdex_stateinfo *instantdex_statecreate(struct instantdex_stateinfo *states,int32_t *numstatesp,char *name,cJSON *(*process_func)(struct supernet_info *myinfo,struct exchange_info *exchange,struct instantdex_accept *A,cJSON *argjson,cJSON *newjson,uint8_t **serdatap,int32_t *serdatalenp),cJSON *(*timeout_func)(struct supernet_info *myinfo,struct exchange_info *exchange,struct instantdex_accept *A,cJSON *argjson,cJSON *newjson,uint8_t **serdatap,int32_t *serdatalenp),char *timeoutstr,char *errorstr)
{
struct instantdex_stateinfo *timeoutstate,*errorstate,*state = 0;
struct instantdex_stateinfo S,*state = 0;
if ( (state= instantdex_statefind(states,*numstatesp,name)) == 0 )
{
states = realloc(states,sizeof(*states) * (*numstatesp + 1));
state = &states[*numstatesp];
memset(state,0,sizeof(*state));
strcpy(state->name,name);
if ( (errorstate= instantdex_statefind(states,*numstatesp,errorstr)) == 0 )
errorstate = &instantdex_errorstate;
state->errorevent = errorstate;
if ( (timeoutstate= instantdex_statefind(states,*numstatesp,timeoutstr)) == 0 )
timeoutstate = &instantdex_timeoutstate;
state->timeoutevent = timeoutstate;
if ( (state->process= process_func) == 0 )
state->process = instantdex_defaultprocess;
if ( (state->timeout= timeout_func) == 0 )
state->timeout = instantdex_defaulttimeout;
instantdex_stateinit(states,*numstatesp,state,name,errorstr,timeoutstr,process_func,timeout_func);
(*numstatesp)++;
} else printf("statecreate error!!! (%s) already exists\n",name);
}
else
{
instantdex_stateinit(states,*numstatesp,&S,name,errorstr,timeoutstr,process_func,timeout_func);
if ( memcmp(&S,state,sizeof(S)) != 0 )
printf("statecreate error!!! (%s) already exists\n",name);
}
return(states);
}
@ -786,7 +798,10 @@ char *instantdex_selectqueue(struct exchange_info *exchange,struct instantdex_ac
free_json(retjson);
}
if ( flag == 0 )
{
printf("add orderid.%llu to statemachine\n",(long long)ap->orderid);
queue_enqueue("statemachineQ",&exchange->statemachineQ,&ap->DL,0);
}
return(retstr);
}

4
iguana/main.c

@ -1107,7 +1107,7 @@ void iguana_main(void *arg)
sleep(1);
char *str;
strcpy(MYINFO.rpcsymbol,"BTC");
iguana_launchcoin(MYINFO.rpcsymbol,cJSON_Parse("{}"));
//iguana_launchcoin(MYINFO.rpcsymbol,cJSON_Parse("{}"));
if ( 1 && (str= SuperNET_JSON(&MYINFO,cJSON_Parse("{\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":128,\"maxpeers\":3,\"newcoin\":\"BTC\",\"active\":0}"),0)) != 0 )
{
free(str);
@ -1121,6 +1121,8 @@ void iguana_main(void *arg)
free(str);
}
}
printf("BTC active.%d BTCD active.%d\n",iguana_coinfind("BTC")->active,iguana_coinfind("BTCD")->active);
iguana_coinfind("BTC")->active = iguana_coinfind("BTCD")->active = 0;
}
sleep(1);
#endif

Loading…
Cancel
Save