Browse Source

Test

etomic
jl777 8 years ago
parent
commit
e61ddd4d17
  1. 1
      iguana/exchanges/LP_include.h
  2. 2
      iguana/exchanges/LP_nativeDEX.c
  3. 9
      iguana/exchanges/LP_utxos.c

1
iguana/exchanges/LP_include.h

@ -169,6 +169,7 @@ struct LP_utxoinfo
void *swap;
uint64_t value,satoshis,value2;
uint8_t key[sizeof(bits256) + sizeof(int32_t)];
uint8_t key2[sizeof(bits256) + sizeof(int32_t)];
int32_t vout,vout2,pair;
uint32_t lasttime,errors,swappending,published,spentflag;
double profitmargin;

2
iguana/exchanges/LP_nativeDEX.c

@ -23,7 +23,7 @@
#include "LP_include.h"
#include "LP_network.c"
struct LP_utxoinfo *LP_utxoinfos;
struct LP_utxoinfo *LP_utxoinfos,*LP_utxoinfos2;
struct LP_peerinfo *LP_peerinfos,*LP_mypeer;
char *activecoins[] = { "BTC", "KMD", "REVS", "JUMBLR" };//"LTC", "USD", };

9
iguana/exchanges/LP_utxos.c

@ -43,6 +43,8 @@ struct LP_utxoinfo *LP_utxofind(bits256 txid,int32_t vout)
memcpy(&key[sizeof(txid)],&vout,sizeof(vout));
portable_mutex_lock(&LP_utxomutex);
HASH_FIND(hh,LP_utxoinfos,key,sizeof(key),utxo);
if ( utxo == 0 )
HASH_FIND(hh,LP_utxoinfos2,key,sizeof(key),utxo);
portable_mutex_unlock(&LP_utxomutex);
return(utxo);
}
@ -107,6 +109,8 @@ void LP_spentnotify(struct LP_utxoinfo *utxo,int32_t selector)
{
cJSON *argjson;
utxo->spentflag = (uint32_t)time(NULL);
if ( LP_mypeer != 0 && LP_mypeer->numutxos > 0 )
LP_mypeer->numutxos--;
if ( LP_mypubsock >= 0 )
{
argjson = cJSON_CreateObject();
@ -181,7 +185,7 @@ struct LP_utxoinfo *LP_addutxo(int32_t amclient,struct LP_peerinfo *mypeer,int32
printf("LP node got localhost utxo\n");
return(0);
}
if ( (utxo= LP_utxofind(txid,vout)) != 0 )
if ( (utxo= LP_utxofind(txid,vout)) != 0 )
{
//printf("%.8f %.8f %.8f vs utxo.(%.8f %.8f %.8f)\n",dstr(value),dstr(value2),dstr(tmpsatoshis),dstr(utxo->value),dstr(utxo->value2),dstr(utxo->satoshis));
if ( bits256_cmp(txid,utxo->txid) != 0 || bits256_cmp(txid2,utxo->txid2) != 0 || vout != utxo->vout || value != utxo->value || tmpsatoshis != utxo->satoshis || vout2 != utxo->vout2 || value2 != utxo->value2 || strcmp(coin,utxo->coin) != 0 || strcmp(spendscript,utxo->spendscript) != 0 || strcmp(coinaddr,utxo->coinaddr) != 0 || strcmp(ipaddr,utxo->ipaddr) != 0 || port != utxo->port )
@ -211,8 +215,11 @@ struct LP_utxoinfo *LP_addutxo(int32_t amclient,struct LP_peerinfo *mypeer,int32
utxo->value2 = value2;
memcpy(utxo->key,txid.bytes,sizeof(txid));
memcpy(&utxo->key[sizeof(txid)],&vout,sizeof(vout));
memcpy(utxo->key2,txid2.bytes,sizeof(txid2));
memcpy(&utxo->key2[sizeof(txid2)],&vout2,sizeof(vout2));
portable_mutex_lock(&LP_utxomutex);
HASH_ADD_KEYPTR(hh,LP_utxoinfos,utxo->key,sizeof(utxo->key),utxo);
HASH_ADD_KEYPTR(hh,LP_utxoinfos2,utxo->key2,sizeof(utxo->key2),utxo);
if ( mypeer != 0 )
mypeer->numutxos++;
portable_mutex_unlock(&LP_utxomutex);

Loading…
Cancel
Save