diff --git a/iguana/exchanges/LP_mpnet.c b/iguana/exchanges/LP_mpnet.c index a0d53b290..36f4a78a7 100644 --- a/iguana/exchanges/LP_mpnet.c +++ b/iguana/exchanges/LP_mpnet.c @@ -103,22 +103,115 @@ void LP_mpnet_send(int32_t localcopy,char *msg,int32_t sendflag,char *otheraddr) } } +cJSON *LP_mpnet_parse(struct iguana_info *coin,bits256 txid) +{ + cJSON *txobj,*argjson = 0; + + return(argjson); +} + // 2151978 // 404bc4ac452db07ed16376b3d7e77dbfc22b4a68f7243797125bd0d3bdddf8d1 // 893b46634456034a6d5d73b67026aa157b5e2addbfc6344dfbea6bae85f7dde0 // 717c7ef9de8504bd331f3ef52ed0a16ea0e070434e12cb4d63f5f081e999c43d dup -cJSON *LP_mpnet_get() +bits256 MPNET_txids[1024]; +int32_t num_MPNET_txids; + +int32_t LP_mpnet_find(bits256 txid) +{ + int32_t i; + for (i=0; i= 0 ) + { + MPNET_txids[i] = MPNET_txids[--num_MPNET_txids]; + return(i); + } + return(-1); +} + +void LP_mpnet_process(void *ctx,char *myipaddr,int32_t pubsock,struct iguana_info *coin,bits256 txid) { + if ( LP_mpnet_find(txid) < 0 ) + { + if ( (argjson= LP_mpnet_parse(coin,txid)) != 0 ) + { + printf("MPNET.(%s)\n",jprint(argjson,0)); + LP_tradecommand(ctx,myipaddr,pubsock,argjson,0,0); + free_json(argjson); + } + LP_mpnet_add(txid); + } +} + +cJSON *LP_mpnet_get(struct iguana_info *coin) +{ + static int32_t lastheight; static bits256 lasthash; + int32_t i,n=0,numtx,checkht = 0,height = 0; bits256 latesthash,zero; char hashstr[65],str[65]; cJSON *txs,*blockjson; + memset(zero.bytes,0,sizeof(zero)); + latesthash = LP_getbestblockhash(coin); + bits256_str(hashstr,latesthash); + if ( (blockjson= LP_blockjson(&checkht,coin->symbol,hashstr,0)) != 0 ) + { + hash = latesthash; + while ( bits256_cmp(lasthash,hash) != 0 && n++ < 3 ) + { + if ( (txs= jarray(&numtx,blockjson,"tx")) != 0 ) + { + for (i=0; isymbol,hashstr,0)) == 0 ) + break; + } + lasthash = latesthash; + if ( blockjson != 0 ) + free_json(blockjson); + if ( (txs= LP_getmempool(coin->symbol,coin->smartaddr,zero,zero)) != 0 ) + { + numtx = cJSON_GetArraySize(txs); + for (i=0; i