Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
333549ff77
  1. 2
      basilisk/basilisk.c
  2. 56
      basilisk/basilisk_bitcoin.c
  3. 5
      iguana/iguana_unspents.c
  4. 2
      iguana/main.c

2
basilisk/basilisk.c

@ -901,7 +901,7 @@ void basilisks_loop(void *arg)
} }
HASH_ITER(hh,myinfo->allcoins,coin,tmpcoin) HASH_ITER(hh,myinfo->allcoins,coin,tmpcoin)
{ {
if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 ) //if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 )
{ {
for (i=0; i<BASILISK_MAXRELAYS; i++) for (i=0; i<BASILISK_MAXRELAYS; i++)
if ( coin->relay_RTheights[i] != 0 ) if ( coin->relay_RTheights[i] != 0 )

56
basilisk/basilisk_bitcoin.c

@ -321,6 +321,7 @@ void *basilisk_bitcoinbalances(struct basilisk_item *Lptr,struct supernet_info *
} }
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
jaddstr(retjson,"result","success"); jaddstr(retjson,"result","success");
jaddstr(retjson,"ipaddr",myinfo->ipaddr);
jaddnum(retjson,"total",dstr(total)); jaddnum(retjson,"total",dstr(total));
jadd(retjson,"addresses",array); jadd(retjson,"addresses",array);
if ( unspents != 0 ) if ( unspents != 0 )
@ -937,7 +938,7 @@ HASH_ARRAY_STRING(basilisk,history,hash,vals,hexstr)
jaddi(array,item); jaddi(array,item);
} }
} }
//printf("%s numunspents.%d\n",waddr->coinaddr,waddr->numunspents); printf("%s numunspents.%d\n",waddr->coinaddr,waddr->numunspents);
} }
} }
portable_mutex_unlock(&myinfo->bu_mutex); portable_mutex_unlock(&myinfo->bu_mutex);
@ -1041,10 +1042,31 @@ void basilisk_unspent_update(struct supernet_info *myinfo,struct iguana_info *co
} }
} }
void basilisk_relay_unspentsprocess(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *relayjson)
{
int32_t RTheight,relayid,num,j; cJSON *unspents,*spends;
RTheight = jint(relayjson,"RTheight");
if ( (relayid= basilisk_relayid(myinfo,(uint32_t)calc_ipbits(jstr(relayjson,"relay")))) < BASILISK_MAXRELAYS )
{
coin->relay_RTheights[relayid] = RTheight;
}
//printf("relayid.%d RT.%d (%s)\n",relayid,RTheight,jprint(relayjson,0));
if ( (unspents= jarray(&num,relayjson,"unspents")) != 0 )
{
for (j=0; j<num; j++)
basilisk_unspent_update(myinfo,coin,jitem(unspents,j),0,relayid,RTheight);
}
if ( (spends= jarray(&num,relayjson,"spends")) != 0 )
{
for (j=0; j<num; j++)
basilisk_unspent_update(myinfo,coin,jitem(spends,j),jint(jitem(spends,j),"spentheight"),relayid,RTheight);
}
}
void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *coin) void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *coin)
{ {
char *retstr; cJSON *retarray,*vals,*relayjson,*unspents,*spends; int32_t oldest,i,j,n,num,RTheight,relayid; char *retstr; cJSON *retarray,*vals; int32_t oldest,i,n,RTheight;
if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 ) //if ( coin->RELAYNODE == 0 && coin->VALIDATENODE == 0 )
{ {
vals = cJSON_CreateObject(); vals = cJSON_CreateObject();
for (i=oldest=0; i<BASILISK_MAXRELAYS; i++) for (i=oldest=0; i<BASILISK_MAXRELAYS; i++)
@ -1052,34 +1074,20 @@ void basilisk_unspents_update(struct supernet_info *myinfo,struct iguana_info *c
oldest = RTheight; oldest = RTheight;
jaddnum(vals,"firstheight",oldest); jaddnum(vals,"firstheight",oldest);
jaddnum(vals,"history",3); jaddnum(vals,"history",3);
jaddstr(vals,"coin",coin->symbol);
if ( (retstr= basilisk_balances(myinfo,coin,0,0,GENESIS_PUBKEY,vals,"")) != 0 ) if ( (retstr= basilisk_balances(myinfo,coin,0,0,GENESIS_PUBKEY,vals,"")) != 0 )
{ {
//printf("GOT.(%s)\n",retstr);
portable_mutex_lock(&myinfo->bu_mutex); portable_mutex_lock(&myinfo->bu_mutex);
if ( (retarray= cJSON_Parse(retstr)) != 0 && (n= cJSON_GetArraySize(retarray)) > 0 ) if ( (retarray= cJSON_Parse(retstr)) != 0 )
{ {
if ( jobj(retarray,"error") == 0 ) if ( jobj(retarray,"error") == 0 )
{ {
for (i=0; i<n; i++) if ( (jstr(retarray,"ipaddr") == 0 || strcmp(jstr(retarray,"ipaddr"),myinfo->ipaddr) != 0) && (n= cJSON_GetArraySize(retarray)) > 0 )
{ {
relayjson = jitem(retarray,i); //printf("n.%d GOT.(%s)\n",n,jprint(retarray,0));
RTheight = jint(relayjson,"RTheight"); for (i=0; i<n; i++)
if ( (relayid= basilisk_relayid(myinfo,(uint32_t)calc_ipbits(jstr(relayjson,"relay")))) < BASILISK_MAXRELAYS ) basilisk_relay_unspentsprocess(myinfo,coin,jitem(retarray,i));
{ } else basilisk_relay_unspentsprocess(myinfo,coin,retarray);
coin->relay_RTheights[relayid] = RTheight;
}
//printf("relayid.%d RT.%d\n",relayid,RTheight);
if ( (unspents= jarray(&num,relayjson,"unspents")) != 0 )
{
for (j=0; j<num; j++)
basilisk_unspent_update(myinfo,coin,jitem(unspents,j),0,relayid,RTheight);
}
if ( (spends= jarray(&num,relayjson,"spends")) != 0 )
{
for (j=0; j<num; j++)
basilisk_unspent_update(myinfo,coin,jitem(spends,j),jint(jitem(spends,j),"spentheight"),relayid,RTheight);
}
}
} }
} }
if ( retarray != 0 ) if ( retarray != 0 )

5
iguana/iguana_unspents.c

@ -115,7 +115,7 @@ cJSON *ramchain_unspentjson(struct iguana_unspent *up,uint32_t unspentind)
cJSON *ramchain_spentjson(struct iguana_info *coin,int32_t spentheight,int32_t hdrsi,int32_t unspentind,bits256 txid,int32_t vout,int64_t uvalue) cJSON *ramchain_spentjson(struct iguana_info *coin,int32_t spentheight,int32_t hdrsi,int32_t unspentind,bits256 txid,int32_t vout,int64_t uvalue)
{ {
char coinaddr[64]; bits256 hash2,*X; struct iguana_txid T,*tx,*spentT,*spent_tx; struct iguana_bundle *bp; int32_t j,i; struct iguana_block *block; int64_t total = 0; struct iguana_unspent *U,*u; struct iguana_pkhash *P; struct iguana_spend *S,*s; struct iguana_ramchaindata *rdata; cJSON *addrs,*item,*voutobj; char coinaddr[64]; bits256 hash2,*X; struct iguana_txid T,*tx,*spentT,*spent_tx; struct iguana_bundle *bp; int32_t j,i,ind; struct iguana_block *block; int64_t total = 0; struct iguana_unspent *U,*u; struct iguana_pkhash *P; struct iguana_spend *S,*s; struct iguana_ramchaindata *rdata; cJSON *addrs,*item,*voutobj;
item = cJSON_CreateObject(); item = cJSON_CreateObject();
hash2 = iguana_blockhash(coin,spentheight); hash2 = iguana_blockhash(coin,spentheight);
if ( (block= iguana_blockfind("spent",coin,hash2)) != 0 && (bp= coin->bundles[spentheight/coin->chain->bundlesize]) != 0 && (rdata= bp->ramchain.H.data) != 0 ) if ( (block= iguana_blockfind("spent",coin,hash2)) != 0 && (bp= coin->bundles[spentheight/coin->chain->bundlesize]) != 0 && (rdata= bp->ramchain.H.data) != 0 )
@ -138,7 +138,8 @@ cJSON *ramchain_spentjson(struct iguana_info *coin,int32_t spentheight,int32_t h
{ {
if ( s->external != 0 ) if ( s->external != 0 )
{ {
if ( bits256_cmp(X[s->spendtxidind],txid) != 0 ) ind = s->spendtxidind & 0xfffffff;
if ( bits256_cmp(X[ind],txid) != 0 )
continue; continue;
} }
else else

2
iguana/main.c

@ -1155,7 +1155,7 @@ void iguana_appletests(struct supernet_info *myinfo)
bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33); bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33);
printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i); printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i);
getchar();**/ getchar();**/
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":1}"),0,myinfo->rpcport)) != 0 ) if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":1}"),0,myinfo->rpcport)) != 0 )
{ {
free(str); free(str);
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":8,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":8,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 )

Loading…
Cancel
Save