diff --git a/qserver/qserver.c b/qserver/qserver.c index e23cba3..dac2a68 100644 --- a/qserver/qserver.c +++ b/qserver/qserver.c @@ -1,10 +1,11 @@ + - -//#define TESTNET +#define TESTNET #define QSERVER // https://www.tecmint.com/increase-set-open-file-limits-in-linux/#:~:text=You%20can%20increase%20the%20limit,configure%20kernel%20parameters%20at%20runtime. // https://unix.stackexchange.com/questions/307046/real-time-file-synchronization // https://github.com/lsyncd/lsyncd/issues/394 +// set timezone! timedatectl set-timezone UTC #include #include @@ -69,7 +70,11 @@ struct assetname int32_t index,extra; } *Assetnames; -#include "qconn.c" +#ifdef __APPLE__ +#include "../qshared/qconn.c" +#else +#include "qshared/qconn.c" +#endif #include "qx.c" #include "qmutex.c" #include "qpeers.c" @@ -586,6 +591,50 @@ void disp_asset(struct Asset *issued,struct Asset *owned) printf("name.(%s) %s %s %s\n",name,amountstr(owned->varStruct.ownership.numberOfUnits),issuer,owner); } +void emit_quote(FILE *fp,int32_t commaflag,struct Orders_Output *quote) +{ + char addr[64]; + pubkey2addr(quote->pubkey,addr); + fprintf(fp,"%s[\"%s\",\"%s\",\"%s\"]",commaflag!=0?",":"",addr,amountstr(quote->numberOfShares),amountstr2(quote->price)); +} + +void emit_quotes(FILE *fp,char *arrayname,struct Orders_Output *quotes,int32_t n) +{ + int32_t i,m = 0; + fprintf(fp,",\"%s\":[",arrayname); + for (i=0; i0,"es[i]); + m++; + //printf("i.%d m.%d %s\n",i,m,amountstr(quotes[i].price)); + } + } + fprintf(fp,"]"); +} + +void emit_orderbook(struct issuerpub *asset) +{ + FILE *fp; + uint8_t zero[32]; + char fname[512],issuer[64]; + sprintf(fname,"%s%corders%c%s",DATADIR,dir_delim(),dir_delim(),asset->name); + if ( (fp= fopen(fname,"w")) != 0 ) + { + memset(zero,0,sizeof(zero)); + if ( memcmp(zero,asset->pubkey,32) == 0 ) + strcpy(issuer,"QubicSmartContract"); + else + pubkey2addr(asset->pubkey,issuer); + fprintf(fp,"{\"name\":\"%s\",\"issuer\":\"%s\"",asset->name,issuer); + emit_quotes(fp,"bids",asset->bids,sizeof(asset->bids)/sizeof(*asset->bids)); + emit_quotes(fp,"asks",asset->asks,sizeof(asset->asks)/sizeof(*asset->asks)); + fprintf(fp,"}"); + fclose(fp); + } +} + void tests(int32_t tick) { #ifdef TESTNET @@ -610,11 +659,11 @@ void tests(int32_t tick) if ( I.tick > LATEST_TICK ) LATEST_TICK = I.tick; INITIAL_TICK = I.initialTick; - if ( tick == 0 ) + //if ( tick == 0 ) { printf("sendmany %s\n",amountstr(getFees((char *)"91.210.226.133",&fees))); printf("sendmany %s\n",amountstr(getFees((char *)"91.210.226.146",&fees))); - printf("sendmany %s\n",amountstr(getFees((char *)"194.158.200.8",&fees))); + //printf("sendmany %s\n",amountstr(getFees((char *)"194.158.200.8",&fees))); printf("sendmany %s\n",amountstr(getFees(DEFAULT_NODE_IP,&fees))); pubkey2addr(pubkey,checkaddr); RespondedEntity E = getBalance(DEFAULT_NODE_IP,DEFAULT_NODE_PORT,pubkey,merkleroot); @@ -627,21 +676,32 @@ void tests(int32_t tick) for (i=0; i EXITFLAG ) @@ -684,6 +742,7 @@ int main(int argc, const char * argv[]) utime = set_current_ymd(&year,&month,&day,&seconds); if ( utime > LATEST_UTIME ) { + tests(LATEST_TICK); LATEST_UTIME = utime; if ( newepochflag != 0 && utime > newepochflag+90 && EXITFLAG == 0 ) EXITFLAG = utime + 30; @@ -704,6 +763,7 @@ int main(int argc, const char * argv[]) } if ( LATEST_TICK > latest && INITIAL_TICK != 0 ) { + tests(LATEST_TICK); numflush = numsub = 0; if ( LATEST_TICK == latest+1 ) { @@ -725,19 +785,22 @@ int main(int argc, const char * argv[]) update_sandwiches(LATEST_TICK); } latest = LATEST_TICK; - tests(LATEST_TICK); + for (i=0; i N*ASSETB+QU trading -> also needs parallel tx +// myorders support can be done via orders files + +// testnet verify tx creation (-issue, -transfer, -bid/ask, cancel bid/ask) +// verify orderbooks +// verify resend of all txtypes +// imported seed entropy calculator -// minimize qclient footprint +// minimize qclient footprint // sendmany txids? -// last + 1 tick should not get tx even if included + +// weekly: update EPOCHS, spectrum/universe, verify supply, relaunches + +