jl777 8 years ago
parent
commit
881d4b15ae
  1. 9
      basilisk/basilisk_CMD.c
  2. 4
      basilisk/basilisk_MSG.c
  3. 11
      iguana/iguana777.h
  4. 59
      iguana/iguana_notary.c
  5. 5
      includes/iguana_funcs.h

9
basilisk/basilisk_CMD.c

@ -24,10 +24,14 @@
return(-1);
}*/
struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *notaries,uint32_t ipbits)
void basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *notaries,uint32_t ipbits)
{
struct iguana_peer *addr; int32_t i; char ipaddr[64];
char ipaddr[64];
expand_ipbits(ipaddr,ipbits);
#if ISNOTARYNODE
dpow_nanomsginit(myinfo,ipaddr);
#else
struct iguana_peer *addr; int32_t i;
if ( notaries == 0 || ipbits == myinfo->myaddr.myipbits )
return(0);
if ( (addr= iguana_peerfindipbits(notaries,ipbits,0)) == 0 )
@ -47,6 +51,7 @@ struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct igu
} else printf("error getting peerslot\n");
} else addr->isrelay = 1;
return(addr);
#endif
}
static int _increasing_ipbits(const void *a,const void *b)

4
basilisk/basilisk_MSG.c

@ -220,8 +220,8 @@ char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int3
// printf("%02x",key[i]);
//printf(" <- ADDMSG.[%d] exp %u %p (%p %p)\n",QUEUEITEMS,msg->expiration,msg,msg->hh.next,msg->hh.prev);
portable_mutex_unlock(&myinfo->messagemutex);
if ( myinfo->NOTARY.RELAYID >= 0 )
dpow_handler(myinfo,msg);
//if ( myinfo->NOTARY.RELAYID >= 0 )
// dpow_handler(myinfo,msg);
if ( sendping != 0 )
queue_enqueue("basilisk_message",&myinfo->msgQ,&msg->DL,0);
return(clonestr("{\"result\":\"message added to hashtable\"}"));

11
iguana/iguana777.h

@ -42,6 +42,17 @@
#define BTC2_DEFAULT_PORT 8222
#define BTC2_DIFF_WINDOW 60
#ifdef __APPLE__
#define ISNOTARYNODE 1
#include "nn.h"
#include "bus.h"
#else
#if ISNOTARYNODE
#include <nanomsg/nn.h>
#include <nanomsg/bus.h>
#endif
#endif
#define DPOW_UTXOCHANNEL ('d' | ('P' << 8) | ('o' << 16) | ('W' << 24))
#define DPOW_UTXOBTCCHANNEL (~DPOW_UTXOCHANNEL)
#define DPOW_SIGCHANNEL ('s' | ('i' << 8) | ('g' << 16) | ('s' << 24))

59
iguana/iguana_notary.c

@ -25,13 +25,20 @@
#include "iguana777.h"
#include "notaries.h"
#ifdef __APPLE__
#define ISNOTARYNODE 1
#include "nn.h"
#else
#if ISNOTARYNODE
#include <nanomsg/nn.h>
#endif
void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr)
{
}
uint32_t dpow_send(struct supernet_info *myinfo,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2])
{
return(basilisk_channelsend(myinfo,srchash,desthash,channel,msgbits,data,datalen,120));
//return(basilisk_crcsend(myinfo,1,bp->sendbuf,sizeof(bp->sendbuf),srchash,desthash,channel,msgbits,data,datalen,crcs));
}
#endif
#define CHECKSIG 0xac
@ -650,12 +657,6 @@ cJSON *dpow_createtx(struct iguana_info *coin,cJSON **vinsp,struct dpow_block *b
return(txobj);
}
uint32_t dpow_send(struct supernet_info *myinfo,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2])
{
return(basilisk_channelsend(myinfo,srchash,desthash,channel,msgbits,data,datalen,120));
//return(basilisk_crcsend(myinfo,1,bp->sendbuf,sizeof(bp->sendbuf),srchash,desthash,channel,msgbits,data,datalen,crcs));
}
void dpow_sigsend(struct supernet_info *myinfo,struct dpow_block *bp,int32_t myind,int8_t bestk,uint64_t bestmask,bits256 srchash,uint32_t sigchannel)
{
struct dpow_sigentry dsig; int32_t i,len; uint8_t data[4096]; struct dpow_entry *ep;
@ -677,8 +678,8 @@ void dpow_sigsend(struct supernet_info *myinfo,struct dpow_block *bp,int32_t myi
void dpow_rawtxsign(struct supernet_info *myinfo,struct iguana_info *coin,struct dpow_block *bp,char *rawtx,cJSON *vins,int8_t bestk,uint64_t bestmask,int32_t myind,uint32_t sigchannel)
{
int32_t j,i,k,n,m=0,flag=0,retval=-1; char *jsonstr,*signedtx,*rawtx2,*sigstr,str[65]; cJSON *txobj,*signobj,*sobj,*txobj2,*item,*vin; bits256 srchash; struct dpow_entry *ep = &bp->notaries[myind];
if ( vins == 0 && bitweight(bestmask) == DPOW_M(bp) )
int32_t j,m=0,flag=0,retval=-1; char *jsonstr,*signedtx,*rawtx2,*sigstr; cJSON *signobj,*sobj,*txobj2,*item,*vin; bits256 srchash; struct dpow_entry *ep = &bp->notaries[myind];
/*if ( vins == 0 && bitweight(bestmask) == DPOW_M(bp) )
{
if ( (rawtx2= dpow_decoderawtransaction(myinfo,coin,rawtx)) != 0 )
{
@ -716,9 +717,9 @@ void dpow_rawtxsign(struct supernet_info *myinfo,struct iguana_info *coin,struct
k++;
}
if ( k != bestk )
printf("extracted uxto k.%d != bestk.%d\n",k,bestk);
printf("extracted uxto k.%d != bestk.%d %llx\n",k,bestk,(long long)bestmask);
}
}
}*/
m = 0;
if ( (jsonstr= dpow_signrawtransaction(myinfo,coin,rawtx,vins)) != 0 )
{
@ -762,7 +763,7 @@ void dpow_rawtxsign(struct supernet_info *myinfo,struct iguana_info *coin,struct
int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct iguana_info *coin,struct dpow_block *bp,int8_t bestk,uint64_t bestmask,int32_t myind,char *opret_symbol,uint32_t sigchannel)
{
int32_t j,incr,len,numsigs,retval=-1; char rawtx[32768]; cJSON *txobj,*vins; bits256 txid,tmp,srchash,zero; struct dpow_entry *ep; uint8_t txdata[32768];
int32_t j,incr,numsigs,retval=-1; char rawtx[32768]; cJSON *txobj,*vins; bits256 txid,srchash,zero; struct dpow_entry *ep;
if ( bp->numnotaries < 8 )
incr = 1;
else incr = sqrt(bp->numnotaries) + 1;
@ -778,16 +779,16 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct iguana_info *coin,s
txid = dpow_notarytx(rawtx,&numsigs,coin->chain->isPoS,bp,opret_symbol);
if ( bits256_nonz(txid) != 0 && rawtx[0] != 0 ) // send tx to share utxo set
{
memset(&tmp,0,sizeof(tmp));
/*memset(&tmp,0,sizeof(tmp));
tmp.ulongs[1] = bestmask;
tmp.bytes[31] = bestk;
len = (int32_t)strlen(rawtx) >> 1;
decode_hex(txdata+32,len,rawtx);
for (j=0; j<sizeof(srchash); j++)
txdata[j] = tmp.bytes[j];
dpow_send(myinfo,bp,zero,bp->hashmsg,(bits256_nonz(bp->btctxid) == 0) ? DPOW_BTCTXIDCHANNEL : DPOW_TXIDCHANNEL,bp->height,txdata,len+32,bp->txidcrcs);
dpow_send(myinfo,bp,zero,bp->hashmsg,(bits256_nonz(bp->btctxid) == 0) ? DPOW_BTCTXIDCHANNEL : DPOW_TXIDCHANNEL,bp->height,txdata,len+32,bp->txidcrcs);*/
dpow_rawtxsign(myinfo,coin,bp,rawtx,vins,bestk,bestmask,myind,sigchannel);
}
dpow_rawtxsign(myinfo,coin,bp,rawtx,vins,bestk,bestmask,myind,sigchannel);
free_json(txobj);
//fprintf(stderr,"free vins\n");
//free_json(vins);
@ -931,13 +932,13 @@ void dpow_datahandler(struct supernet_info *myinfo,struct dpow_block *bp,uint32_
{
for (i=0; i<32; i++)
srchash.bytes[i] = data[i];
if ( srchash.ulongs[0] == 0 )
/*if ( srchash.ulongs[0] == 0 )
{
init_hexbytes_noT(bp->rawtx,&data[32],datalen-32);
//printf("got bestk.%d %llx rawtx.(%s) set utxo\n",srchash.bytes[31],(long long)srchash.ulongs[1],bp->rawtx);
dpow_rawtxsign(myinfo,bp->coin,bp,bp->rawtx,0,srchash.bytes[31],srchash.ulongs[1],myind,bits256_nonz(bp->btctxid) == 0 ? DPOW_SIGBTCCHANNEL : DPOW_SIGCHANNEL);
}
else
else*/
{
txid = bits256_doublesha256(0,&data[32],datalen-32);
init_hexbytes_noT(bp->signedtx,&data[32],datalen-32);
@ -959,7 +960,7 @@ void dpow_datahandler(struct supernet_info *myinfo,struct dpow_block *bp,uint32_
}
}
void dpow_handler(struct supernet_info *myinfo,struct basilisk_message *msg)
/*void dpow_handler(struct supernet_info *myinfo,struct basilisk_message *msg)
{
bits256 srchash,desthash; uint32_t channel,height;
basilisk_messagekeyread(msg->key,&channel,&height,&srchash,&desthash);
@ -994,27 +995,27 @@ void dpow_channelget(struct supernet_info *myinfo,struct dpow_block *bp,uint32_t
}
free_json(retarray);
}
}
}*/
int32_t dpow_update(struct supernet_info *myinfo,struct dpow_block *bp,uint32_t channel,uint32_t sigchannel,uint32_t txidchannel,bits256 srchash,int32_t myind)
{
struct dpow_entry *ep;
ep = &bp->notaries[myind];
dpow_channelget(myinfo,bp,channel);
//dpow_channelget(myinfo,bp,channel);
if ( (bp->bestk= dpow_bestk(bp,&bp->bestmask)) >= 0 )
{
if ( ep->masks[bp->bestk] == 0 )
dpow_signedtxgen(myinfo,bp->coin,bp,bp->bestk,bp->bestmask,myind,bp->opret_symbol,sigchannel);
else dpow_sigsend(myinfo,bp,myind,bp->bestk,bp->bestmask,srchash,sigchannel);
//else dpow_sigsend(myinfo,bp,myind,bp->bestk,bp->bestmask,srchash,sigchannel);
}
dpow_channelget(myinfo,bp,txidchannel);
//dpow_channelget(myinfo,bp,txidchannel);
if ( bp->state != 0xffffffff )
{
dpow_channelget(myinfo,bp,sigchannel);
//dpow_channelget(myinfo,bp,sigchannel);
if ( ep->masks[bp->bestk] == 0 )
dpow_signedtxgen(myinfo,bp->coin,bp,bp->bestk,bp->bestmask,myind,bp->opret_symbol,sigchannel);
else dpow_sigsend(myinfo,bp,myind,bp->bestk,bp->bestmask,srchash,sigchannel);
//else dpow_sigsend(myinfo,bp,myind,bp->bestk,bp->bestmask,srchash,sigchannel);
}
return(bp->state);
}

5
includes/iguana_funcs.h

@ -497,7 +497,7 @@ struct exchange_info *exchange_create(char *exchangestr,cJSON *argjson);
int32_t iguana_inv2poll(struct supernet_info *myinfo,struct iguana_info *coin);
struct iguana_bundlereq *iguana_bundlereq(struct iguana_info *coin,struct iguana_peer *addr,int32_t type,uint8_t *data,int32_t datalen);
void instantdex_FSMinit();
void dpow_handler(struct supernet_info *myinfo,struct basilisk_message *msg);
//void dpow_handler(struct supernet_info *myinfo,struct basilisk_message *msg);
int32_t datachain_opreturnscript(struct iguana_info *coin,uint8_t *script,char *datastr,int32_t datalen);
int32_t basilisk_messagekeyread(uint8_t *key,uint32_t *channelp,uint32_t *msgidp,bits256 *srchashp,bits256 *desthashp);
cJSON *basilisk_channelget(struct supernet_info *myinfo,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgid,int32_t width);
@ -580,7 +580,8 @@ struct iguana_peer *iguana_peerfindipbits(struct iguana_info *coin,uint32_t ipbi
int32_t basilisk_hashes_send(struct supernet_info *myinfo,struct iguana_info *virt,struct iguana_peer *addr,char *CMD,bits256 *txids,int32_t num);
int32_t iguana_opreturn(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,int64_t crypto777_payment,int32_t height,uint64_t hdrsi_unspentind,int64_t payment,uint32_t fileid,uint64_t scriptpos,uint32_t scriptlen);
int32_t iguana_scriptdata(struct iguana_info *coin,uint8_t *scriptspace,long fileptr[2],char *fname,uint64_t scriptpos,int32_t scriptlen);
struct iguana_peer *basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *notaries,uint32_t ipbits);
void basilisk_ensurerelay(struct supernet_info *myinfo,struct iguana_info *notaries,uint32_t ipbits);
void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr);
int32_t iguana_datachain_scan(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t rmd160[20]);
void basilisk_requests_poll(struct supernet_info *myinfo);

Loading…
Cancel
Save