jl777 8 years ago
parent
commit
900a651c80
  1. 1
      README.md
  2. 7
      iguana/dPoW.h
  3. 68
      iguana/iguana_notary.c

1
README.md

@ -159,6 +159,7 @@ the idea is to issue a curl command into a /tmp/file and then use jsoncmp to ver
##### ../agents/iguana notary
0.Have iguana installed at http://wiki.supernet.org/wiki/How_To_Install_Iguana_on_Linux
also install nanomsg: sudo apt-get install libnanomsg-dev
ports 7774 and 7775 will be used
cd Supernet/iguana -->

7
iguana/dPoW.h

@ -34,7 +34,7 @@ struct dpow_entry
uint64_t masks[DPOW_MAXRELAYS],recvmask;
int32_t prev_vout,height;
int8_t bestk;
uint8_t pubkey[33],siglens[DPOW_MAXRELAYS],sigs[DPOW_MAXRELAYS][76];
uint8_t pubkey[33],siglens[DPOW_MAXRELAYS],sigs[DPOW_MAXRELAYS][0x100];
};
struct dpow_sigentry
@ -42,7 +42,7 @@ struct dpow_sigentry
bits256 beacon;
uint64_t mask;
int32_t refcount;
uint8_t senderind,lastk,siglen,sig[80],senderpub[33];
uint8_t senderind,lastk,siglen,sig[0x100],senderpub[33];
};
struct komodo_notaries
@ -64,7 +64,7 @@ struct dpow_block
uint32_t state,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2];
int32_t height,numnotaries,completed;
int8_t bestk;
char signedtx[32768],rawtx[32768];
char signedtx[32768];//,rawtx[32768];
};
struct dpow_info
@ -74,6 +74,7 @@ struct dpow_info
struct dpow_hashheight approved[DPOW_FIFOSIZE],notarized[DPOW_FIFOSIZE];
bits256 srctx[DPOW_MAXTX],desttx[DPOW_MAXTX];
uint32_t destupdated,srcconfirms,numdesttx,numsrctx,lastsplit;
int32_t sock;
struct dpow_block **srcblocks,**destblocks;
};

68
iguana/iguana_notary.c

@ -28,17 +28,80 @@
#if ISNOTARYNODE
void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr)
struct dpow_nanomsghdr
{
bits256 srchash,desthash;
uint32_t channel,height,size,crc32;
uint8_t packet[];
};
char *nanomsg_tcpname(char *str,char *ipaddr)
{
sprintf(str,"tcp://%s:7774",ipaddr);
return(str);
}
void dpow_nanomsginit(struct supernet_info *myinfo,char *ipaddr)
{
char str[512]; int32_t timeout;
if ( myinfo->DPOW.sock < 0 && (myinfo->DPOW.sock= nn_socket(AF_SP,NN_BUS)) >= 0 )
{
if ( nn_bind(myinfo->DPOW.sock,nanomsg_tcpname(str,myinfo->ipaddr)) < 0 )
{
printf("error binding to (%s)\n",nanomsg_tcpname(str,myinfo->ipaddr));
nn_close(myinfo->DPOW.sock);
myinfo->DPOW.sock = -1;
}
timeout = 100;
nn_setsockopt(myinfo->DPOW.sock,NN_SOL_SOCKET,NN_RCVTIMEO,&timeout,sizeof(timeout));
}
if ( myinfo->DPOW.sock >= 0 && strcmp(ipaddr,myinfo->ipaddr) != 0 )
nn_connect(myinfo->DPOW.sock,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));
struct dpow_nanomsghdr *np; int32_t size,sentbytes;
size = (int32_t)(sizeof(*np) + datalen);
np = malloc(size);
np->size = size;
np->crc32 = calc_crc32(0,data,datalen);
np->srchash = srchash;
np->desthash = desthash;
np->channel = channel;
np->height = msgbits;
memcpy(np->packet,data,datalen);
sentbytes = nn_send(myinfo->DPOW.sock,np,size,0);
free(np);
return(sentbytes);
//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_nanomsg_update(struct supernet_info *myinfo)
{
int32_t size; struct dpow_nanomsghdr *np;
while ( (size= nn_recv(myinfo->DPOW.sock,&np,NN_MSG,0)) >= 0 )
{
if ( size >= 0 )
{
printf("NANORECV ht.%d channel.%08x (%d) crc32.%08x\n",np->height,np->channel,size,np->crc32);
if ( np != 0 )
nn_freemsg(np);
}
}
}
#else
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(0);
}
void dpow_nanomsg_update(struct supernet_info *myinfo) { }
#endif
#define CHECKSIG 0xac
@ -1315,6 +1378,7 @@ void dpow_destupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t h
void iguana_dPoWupdate(struct supernet_info *myinfo)
{
int32_t height; char str[65]; uint32_t blocktime; bits256 blockhash; struct iguana_info *src,*dest; struct dpow_info *dp = &myinfo->DPOW;
dpow_nanomsg_update(myinfo);
src = iguana_coinfind(dp->symbol);
dest = iguana_coinfind(dp->dest);
if ( src != 0 && dest != 0 )

Loading…
Cancel
Save