@@ -5,7 +5,7 @@ RUN apt-get -y update && \
|
||||
apt-get -y upgrade && \
|
||||
apt-get -y install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev \
|
||||
unzip python zlib1g-dev wget bsdmainutils automake libssl-dev libprotobuf-dev \
|
||||
protobuf-compiler libqrencode-dev libdb++-dev software-properties-common libcurl4-openssl-dev && \
|
||||
protobuf-compiler libqrencode-dev libdb++-dev software-properties-common libcurl4-openssl-dev curl && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ Dependencies
|
||||
|
||||
```
|
||||
#The following packages are needed:
|
||||
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl3-gnutls-dev bsdmainutils automake
|
||||
sudo apt-get install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev unzip git python python-zmq zlib1g-dev wget libcurl4-openssl-dev bsdmainutils automake curl
|
||||
```
|
||||
|
||||
Komodo
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
#include "komodo_cJSON.c"
|
||||
#include "komodo_notary.h"
|
||||
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth)
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -33,5 +33,3 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp
|
||||
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BNTN\",\"pubkey\":\"$pubkey\"}"
|
||||
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PRLPAY\",\"pubkey\":\"$pubkey\"}"
|
||||
|
||||
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"USD\",\"pubkey\":\"$pubkey\"}"
|
||||
#curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EUR\",\"pubkey\":\"$pubkey\"}"
|
||||
|
||||
41
src/komodo.h
41
src/komodo.h
@@ -120,7 +120,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char
|
||||
MoMdepth = 0;
|
||||
}
|
||||
//if ( matched != 0 ) global independent states -> inside *sp
|
||||
komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height,MoM,MoMdepth);
|
||||
komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height);//,MoM,MoMdepth);
|
||||
}
|
||||
else if ( func == 'U' ) // deprecated
|
||||
{
|
||||
@@ -265,7 +265,7 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long
|
||||
memset(&MoM,0,sizeof(MoM));
|
||||
MoMdepth = 0;
|
||||
}
|
||||
komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height,MoM,MoMdepth);
|
||||
komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height);//,MoM,MoMdepth);
|
||||
}
|
||||
else if ( func == 'U' ) // deprecated
|
||||
{
|
||||
@@ -349,7 +349,7 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long
|
||||
return(-1);
|
||||
}
|
||||
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth)
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout)//,uint256 MoM,int32_t MoMdepth)
|
||||
{
|
||||
static FILE *fp; static int32_t errs,didinit; static uint256 zero;
|
||||
struct komodo_state *sp; char fname[512],symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t retval,ht,func; uint8_t num,pubkeys[64][33];
|
||||
@@ -480,9 +480,10 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
|
||||
//printf("ht.%d func N ht.%d errs.%d\n",height,NOTARIZED_HEIGHT,errs);
|
||||
if ( sp != 0 )
|
||||
{
|
||||
if ( sp->MoMdepth > 0 && sp->MoM != zero )
|
||||
fputc('M',fp);
|
||||
else fputc('N',fp);
|
||||
//if ( sp->MoMdepth > 0 && sp->MoM != zero )
|
||||
// fputc('M',fp);
|
||||
//else
|
||||
fputc('N',fp);
|
||||
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
|
||||
errs++;
|
||||
if ( fwrite(&sp->NOTARIZED_HEIGHT,1,sizeof(sp->NOTARIZED_HEIGHT),fp) != sizeof(sp->NOTARIZED_HEIGHT) )
|
||||
@@ -491,14 +492,14 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
|
||||
errs++;
|
||||
if ( fwrite(&sp->NOTARIZED_DESTTXID,1,sizeof(sp->NOTARIZED_DESTTXID),fp) != sizeof(sp->NOTARIZED_DESTTXID) )
|
||||
errs++;
|
||||
if ( sp->MoMdepth > 0 && sp->MoM != zero )
|
||||
/*if ( sp->MoMdepth > 0 && sp->MoM != zero )
|
||||
{
|
||||
if ( fwrite(&sp->MoM,1,sizeof(sp->MoM),fp) != sizeof(sp->MoM) )
|
||||
errs++;
|
||||
if ( fwrite(&sp->MoMdepth,1,sizeof(sp->MoMdepth),fp) != sizeof(sp->MoMdepth) )
|
||||
errs++;
|
||||
}
|
||||
komodo_eventadd_notarized(sp,symbol,height,dest,sp->NOTARIZED_HASH,sp->NOTARIZED_DESTTXID,sp->NOTARIZED_HEIGHT,sp->MoM,sp->MoMdepth);
|
||||
}*/
|
||||
komodo_eventadd_notarized(sp,symbol,height,dest,sp->NOTARIZED_HASH,sp->NOTARIZED_DESTTXID,sp->NOTARIZED_HEIGHT);//,sp->MoM,sp->MoMdepth);
|
||||
}
|
||||
}
|
||||
fflush(fp);
|
||||
@@ -587,7 +588,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
||||
{
|
||||
if ( last_rewind != 0 )
|
||||
{
|
||||
KOMODO_REWIND = rewindtarget;
|
||||
//KOMODO_REWIND = rewindtarget;
|
||||
fprintf(stderr,"%s FORK detected. notarized.%d %s not in this chain! last notarization %d -> rewindtarget.%d\n",ASSETCHAINS_SYMBOL,*notarizedheightp,srchash.ToString().c_str(),sp->NOTARIZED_HEIGHT,rewindtarget);
|
||||
}
|
||||
last_rewind = rewindtarget;
|
||||
@@ -599,7 +600,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
||||
sp->NOTARIZED_HEIGHT = *notarizedheightp;
|
||||
sp->NOTARIZED_HASH = srchash;
|
||||
sp->NOTARIZED_DESTTXID = desttxid;
|
||||
memset(&sp->MoM,0,sizeof(sp->MoM));
|
||||
/*memset(&sp->MoM,0,sizeof(sp->MoM));
|
||||
sp->MoMdepth = 0;
|
||||
if ( len+36 <= opretlen )
|
||||
{
|
||||
@@ -614,11 +615,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
||||
{
|
||||
//printf("VALID %s MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,sp->MoM.ToString().c_str(),sp->MoMdepth);
|
||||
}
|
||||
}
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth);
|
||||
}*/
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0);//,sp->MoM,sp->MoMdepth);
|
||||
len += nameoffset;
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth);
|
||||
//if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
// printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,srchash.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth);
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
{
|
||||
if ( signedfp == 0 )
|
||||
@@ -640,7 +641,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
||||
//for (i=0; i<opretlen-len; i++)
|
||||
// printf("%02x",scriptbuf[len+i]);
|
||||
//printf(" Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len);
|
||||
komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len+4+3+(scriptbuf[1] == 0x4d),j,zero,0);
|
||||
komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len+4+3+(scriptbuf[1] == 0x4d),j);//,zero,0);
|
||||
}
|
||||
}
|
||||
} else if ( *notarizedheightp != sp->NOTARIZED_HEIGHT )
|
||||
@@ -669,7 +670,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
||||
}
|
||||
|
||||
if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A')) ) // && scriptbuf[len] != 'I')
|
||||
komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j,zero,0);
|
||||
komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j);//,zero,0);
|
||||
}
|
||||
}
|
||||
return(notaryid);
|
||||
@@ -728,7 +729,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
if ( pindex->nHeight != hwmheight )
|
||||
printf("%s hwmheight.%d vs pindex->nHeight.%d t.%u reorg.%d\n",ASSETCHAINS_SYMBOL,hwmheight,pindex->nHeight,(uint32_t)pindex->nTime,hwmheight-pindex->nHeight);
|
||||
komodo_event_rewind(sp,symbol,pindex->nHeight);
|
||||
komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0,zero,0);
|
||||
komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0);//,zero,0);
|
||||
}
|
||||
komodo_currentheight_set(chainActive.Tip()->nHeight);
|
||||
if ( pindex != 0 )
|
||||
@@ -860,7 +861,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries/3) )
|
||||
{
|
||||
memset(&txhash,0,sizeof(txhash));
|
||||
komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0,zero,0);
|
||||
komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0);//,zero,0);
|
||||
printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height);
|
||||
} else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries);
|
||||
}
|
||||
@@ -869,7 +870,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
if ( NOTARY_PUBKEY33[0] != 0 && ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
printf("%s ht.%d\n",ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL,height);
|
||||
if ( pindex->nHeight == hwmheight )
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0,zero,0);
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0);//,zero,0);
|
||||
} else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n");
|
||||
//KOMODO_INITDONE = (uint32_t)time(NULL);
|
||||
//fprintf(stderr,"%s end connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight);
|
||||
|
||||
@@ -651,7 +651,6 @@ int32_t komodo_block2height(CBlock *block)
|
||||
}
|
||||
if ( height != height2 )
|
||||
{
|
||||
fprintf(stderr,"block2height height.%d vs height2.%d, match.%d mismatch.%d\n",height,height2,match,mismatch);
|
||||
mismatch++;
|
||||
if ( height2 >= 0 )
|
||||
height = height2;
|
||||
@@ -900,7 +899,7 @@ int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t heigh
|
||||
return(0);
|
||||
}
|
||||
|
||||
int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip)
|
||||
/*int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip)
|
||||
{
|
||||
int32_t depth,notarized_ht; uint256 MoM,kmdtxid;
|
||||
depth = komodo_MoMdata(¬arized_ht,&MoM,&kmdtxid,nHeight,MoMoMp,MoMoMoffsetp,MoMoMdepthp,kmdstartip,kmdendip);
|
||||
@@ -915,6 +914,7 @@ int32_t komodo_MoM(int32_t *notarized_heightp,uint256 *MoMp,uint256 *kmdtxidp,in
|
||||
}
|
||||
return(depth);
|
||||
}
|
||||
*/
|
||||
|
||||
int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash)
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char
|
||||
return(ep);
|
||||
}
|
||||
|
||||
void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t height,char *dest,uint256 notarized_hash,uint256 notarized_desttxid,int32_t notarizedheight,uint256 MoM,int32_t MoMdepth)
|
||||
void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t height,char *dest,uint256 notarized_hash,uint256 notarized_desttxid,int32_t notarizedheight)//,uint256 MoM,int32_t MoMdepth)
|
||||
{
|
||||
struct komodo_event_notarized N;
|
||||
if ( NOTARY_PUBKEY33[0] != 0 && komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid) != 0 )
|
||||
@@ -53,12 +53,12 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig
|
||||
N.blockhash = notarized_hash;
|
||||
N.desttxid = notarized_desttxid;
|
||||
N.notarizedheight = notarizedheight;
|
||||
N.MoM = MoM;
|
||||
N.MoMdepth = MoMdepth;
|
||||
//N.MoM = MoM;
|
||||
//N.MoMdepth = MoMdepth;
|
||||
strncpy(N.dest,dest,sizeof(N.dest)-1);
|
||||
komodo_eventadd(sp,height,symbol,KOMODO_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N));
|
||||
if ( sp != 0 )
|
||||
komodo_notarized_update(sp,height,notarizedheight,notarized_hash,notarized_desttxid,MoM,MoMdepth);
|
||||
komodo_notarized_update(sp,height,notarizedheight,notarized_hash,notarized_desttxid);//,MoM,MoMdepth);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,13 +16,12 @@
|
||||
#include "komodo_defs.h"
|
||||
|
||||
uint32_t komodo_heightstamp(int32_t height);
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint32_t ktime,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth);
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint32_t ktime,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout);
|
||||
void komodo_init(int32_t height);
|
||||
int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip);
|
||||
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp);
|
||||
char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port);
|
||||
void komodo_init(int32_t height);
|
||||
void komodo_assetchain_pubkeys(char *jsonstr);
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t komodo_isrealtime(int32_t *kmdheightp);
|
||||
uint64_t komodo_paxtotal();
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
* *
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include "komodo_defs.h"
|
||||
|
||||
#include "komodo_cJSON.h"
|
||||
@@ -199,7 +200,7 @@ const char *Notaries_elected1[][2] =
|
||||
|
||||
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp)
|
||||
{
|
||||
static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1;
|
||||
static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1;
|
||||
int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp;
|
||||
if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
timestamp = komodo_heightstamp(height);
|
||||
@@ -211,29 +212,30 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
|
||||
{
|
||||
if ( did0 == 0 )
|
||||
{
|
||||
n = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0));
|
||||
for (i=0; i<n; i++)
|
||||
n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0));
|
||||
for (i=0; i<n0; i++)
|
||||
decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]);
|
||||
did0 = 1;
|
||||
}
|
||||
memcpy(pubkeys,elected_pubkeys0,n * 33);
|
||||
memcpy(pubkeys,elected_pubkeys0,n0 * 33);
|
||||
//if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
//fprintf(stderr,"%s height.%d t.%u elected.%d notaries\n",ASSETCHAINS_SYMBOL,height,timestamp,n);
|
||||
//fprintf(stderr,"%s height.%d t.%u elected.%d notaries\n",ASSETCHAINS_SYMBOL,height,timestamp,n0);
|
||||
return(n0);
|
||||
}
|
||||
else //if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP2) || height <= KOMODO_NOTARIES_HEIGHT2 )
|
||||
{
|
||||
if ( did1 == 0 )
|
||||
{
|
||||
n = (int32_t)(sizeof(Notaries_elected1)/sizeof(*Notaries_elected1));
|
||||
for (i=0; i<n; i++)
|
||||
n1 = (int32_t)(sizeof(Notaries_elected1)/sizeof(*Notaries_elected1));
|
||||
for (i=0; i<n1; i++)
|
||||
decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]);
|
||||
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
fprintf(stderr,"%s height.%d t.%u elected.%d notaries2\n",ASSETCHAINS_SYMBOL,height,timestamp,n);
|
||||
fprintf(stderr,"%s height.%d t.%u elected.%d notaries2\n",ASSETCHAINS_SYMBOL,height,timestamp,n1);
|
||||
did1 = 1;
|
||||
}
|
||||
memcpy(pubkeys,elected_pubkeys1,n * 33);
|
||||
memcpy(pubkeys,elected_pubkeys1,n1 * 33);
|
||||
return(n1);
|
||||
}
|
||||
return(n);
|
||||
}
|
||||
htind = height / KOMODO_ELECTION_GAP;
|
||||
if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP )
|
||||
@@ -398,8 +400,7 @@ int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct notarized_checkpoint *komodo_npptr(int32_t height)
|
||||
/*struct notarized_checkpoint *komodo_npptr(int32_t height)
|
||||
{
|
||||
char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0;
|
||||
if ( (sp= komodo_stateptr(symbol,dest)) != 0 )
|
||||
@@ -434,8 +435,7 @@ int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,in
|
||||
memset(MoMoMp,0,sizeof(*MoMoMp));
|
||||
memset(kmdtxidp,0,sizeof(*kmdtxidp));
|
||||
return(0);
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp)
|
||||
{
|
||||
@@ -493,7 +493,7 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n
|
||||
return(0);
|
||||
}
|
||||
|
||||
void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth)
|
||||
void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid)//,uint256 MoM,int32_t MoMdepth)
|
||||
{
|
||||
struct notarized_checkpoint *np;
|
||||
if ( notarized_height >= nHeight )
|
||||
@@ -511,8 +511,8 @@ void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t not
|
||||
sp->NOTARIZED_HEIGHT = np->notarized_height = notarized_height;
|
||||
sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash;
|
||||
sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid;
|
||||
sp->MoM = np->MoM = MoM;
|
||||
sp->MoMdepth = np->MoMdepth = MoMdepth;
|
||||
//sp->MoM = np->MoM = MoM;
|
||||
//sp->MoMdepth = np->MoMdepth = MoMdepth;
|
||||
portable_mutex_unlock(&komodo_mutex);
|
||||
}
|
||||
|
||||
@@ -540,21 +540,9 @@ void komodo_init(int32_t height)
|
||||
//for (i=0; i<sizeof(Minerids); i++)
|
||||
// Minerids[i] = -2;
|
||||
didinit = 1;
|
||||
komodo_stateupdate(0,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,zero,0);
|
||||
komodo_stateupdate(0,0,0,0,zero,0,0,0,0,0,0,0,0,0,0);
|
||||
}
|
||||
/*else if ( 0 && height == KOMODO_MAINNET_START )
|
||||
{
|
||||
n = (int32_t)(sizeof(Notaries_elected)/sizeof(*Notaries_elected));
|
||||
for (k=0; k<n; k++)
|
||||
{
|
||||
if ( Notaries_elected[k][0] == 0 || Notaries_elected[k][1] == 0 || Notaries_elected[k][0][0] == 0 || Notaries_elected[k][1][0] == 0 )
|
||||
break;
|
||||
decode_hex(pubkeys[k],33,(char *)Notaries_elected[k][1]);
|
||||
}
|
||||
printf("set MAINNET notaries.%d\n",k);
|
||||
komodo_notarysinit(KOMODO_MAINNET_START,pubkeys,k);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
/*void komodo_assetchain_pubkeys(char *jsonstr)
|
||||
{
|
||||
|
||||
@@ -709,7 +709,7 @@ void komodo_paxpricefeed(int32_t height,uint8_t *pricefeed,int32_t opretlen)
|
||||
double KMDBTC,BTCUSD,CNYUSD; uint32_t numpvals,timestamp,pvals[128]; uint256 zero;
|
||||
numpvals = dpow_readprices(height,pricefeed,×tamp,&KMDBTC,&BTCUSD,&CNYUSD,pvals);
|
||||
memset(&zero,0,sizeof(zero));
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,pvals,numpvals,0,0,0,0,0,0,zero,0);
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,pvals,numpvals,0,0,0,0,0,0);
|
||||
if ( 0 )
|
||||
{
|
||||
int32_t i;
|
||||
|
||||
2434
src/main.cpp
2434
src/main.cpp
File diff suppressed because it is too large
Load Diff
@@ -447,7 +447,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex);
|
||||
bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, bool* pfClean = NULL);
|
||||
|
||||
/** Apply the effects of this block (with given index) on the UTXO set represented by coins */
|
||||
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, bool fJustCheck = false);
|
||||
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, bool fJustCheck = false,bool fCheckPOW = false);
|
||||
|
||||
/** Context-independent validity checks */
|
||||
bool CheckBlockHeader(int32_t height,CBlockIndex *pindex,const CBlockHeader& block, CValidationState& state, bool fCheckPOW = true);
|
||||
|
||||
@@ -112,6 +112,7 @@ extern std::string NOTARY_PUBKEY;
|
||||
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33];
|
||||
uint32_t Mining_start,Mining_height;
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]);
|
||||
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize);
|
||||
uint64_t komodo_paxtotal();
|
||||
int32_t komodo_baseid(char *origbase);
|
||||
@@ -385,7 +386,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
nLastBlockTx = nBlockTx;
|
||||
nLastBlockSize = nBlockSize;
|
||||
blocktime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
||||
pblock->nTime = blocktime + 1;
|
||||
//pblock->nTime = blocktime + 1;
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||
//LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits);
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_STAKED != 0 && NOTARY_PUBKEY33[0] != 0 )
|
||||
@@ -479,8 +480,11 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
// Fill in header
|
||||
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
|
||||
pblock->hashReserved = uint256();
|
||||
//UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
|
||||
//pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 || ASSETCHAINS_STAKED == 0 || NOTARY_PUBKEY33[0] == 0 )
|
||||
{
|
||||
UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||
}
|
||||
pblock->nSolution.clear();
|
||||
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
|
||||
|
||||
@@ -488,8 +492,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false))
|
||||
{
|
||||
static uint32_t counter;
|
||||
if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 )
|
||||
fprintf(stderr,"warning: testblockvalidity failed\n");
|
||||
//if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 )
|
||||
fprintf(stderr,"warning: miner testblockvalidity failed\n");
|
||||
return(0);
|
||||
}
|
||||
}
|
||||
@@ -914,6 +918,12 @@ void static BitcoinMiner()
|
||||
// fprintf(stderr," missed target\n");
|
||||
return false;
|
||||
}
|
||||
CValidationState state;
|
||||
if ( !TestBlockValidity(state, *pblock, chainActive.Tip(), true, false))
|
||||
{
|
||||
fprintf(stderr,"Invalid block mined, try again\n");
|
||||
return(false);
|
||||
}
|
||||
if ( ASSETCHAINS_STAKED == 0 )
|
||||
{
|
||||
if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay )
|
||||
@@ -931,12 +941,6 @@ void static BitcoinMiner()
|
||||
}
|
||||
else
|
||||
{
|
||||
CValidationState state;
|
||||
if ( !TestBlockValidity(state, *pblock, chainActive.Tip(), false, false))
|
||||
{
|
||||
//fprintf(stderr,"Invalid block mined, try again\n");
|
||||
return(false);
|
||||
}
|
||||
if ( NOTARY_PUBKEY33[0] != 0 )
|
||||
{
|
||||
printf("need to wait %d seconds to submit\n",(int32_t)(pblock->nTime - GetAdjustedTime()));
|
||||
|
||||
@@ -116,6 +116,7 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t komodo_chainactive_timestamp();
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t komodo_is_special(uint8_t pubkeys[66][33],int32_t mids[66],int32_t height,uint8_t pubkey33[33],uint32_t timestamp);
|
||||
int32_t komodo_currentheight();
|
||||
|
||||
@@ -589,6 +589,7 @@ UniValue kvsearch(const UniValue& params, bool fHelp)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
UniValue height_MoM(const UniValue& params, bool fHelp)
|
||||
{
|
||||
int32_t height,depth,notarized_height,MoMoMdepth,MoMoMoffset,kmdstarti,kmdendi; uint256 MoM,MoMoM,kmdtxid; uint32_t timestamp = 0; UniValue ret(UniValue::VOBJ); UniValue a(UniValue::VARR);
|
||||
@@ -716,6 +717,7 @@ UniValue txMoMproof(const UniValue& params, bool fHelp)
|
||||
ssProof << MoMProof(nIndex, branch, notarisationHash);
|
||||
return HexStr(ssProof.begin(), ssProof.end());
|
||||
}
|
||||
*/
|
||||
|
||||
UniValue minerids(const UniValue& params, bool fHelp)
|
||||
{
|
||||
@@ -732,7 +734,7 @@ UniValue minerids(const UniValue& params, bool fHelp)
|
||||
if ( pblockindex != 0 )
|
||||
timestamp = pblockindex->GetBlockTime();
|
||||
}
|
||||
if ( 0 && (n= komodo_minerids(minerids,height,(int32_t)(sizeof(minerids)/sizeof(*minerids)))) > 0 )
|
||||
if ( (n= komodo_minerids(minerids,height,(int32_t)(sizeof(minerids)/sizeof(*minerids)))) > 0 )
|
||||
{
|
||||
memset(tally,0,sizeof(tally));
|
||||
numnotaries = komodo_notaries(pubkeys,height,timestamp);
|
||||
|
||||
@@ -125,8 +125,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
||||
{ "paxprices", 3 },
|
||||
{ "paxpending", 0 },
|
||||
{ "notaries", 2 },
|
||||
{ "height_MoM", 1 },
|
||||
{ "txMoMproof", 1 },
|
||||
//{ "height_MoM", 1 },
|
||||
//{ "txMoMproof", 1 },
|
||||
{ "minerids", 1 },
|
||||
{ "kvsearch", 1 },
|
||||
{ "kvupdate", 4 },
|
||||
|
||||
@@ -52,6 +52,7 @@ extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE;
|
||||
extern char ASSETCHAINS_SYMBOL[];
|
||||
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
|
||||
#define KOMODO_VERSION "0.1.1"
|
||||
uint32_t komodo_chainactive_timestamp();
|
||||
|
||||
UniValue getinfo(const UniValue& params, bool fHelp)
|
||||
{
|
||||
|
||||
@@ -165,6 +165,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t KOMODO_LONGESTCHAIN;
|
||||
int32_t komodo_longestchain()
|
||||
{
|
||||
int32_t ht,n=0,num=0,maxheight=0,height = 0;
|
||||
@@ -191,8 +192,12 @@ int32_t komodo_longestchain()
|
||||
height = ht;
|
||||
}
|
||||
if ( num > (n >> 1) )
|
||||
{
|
||||
KOMODO_LONGESTCHAIN = height;
|
||||
return(height);
|
||||
else return(0);
|
||||
}
|
||||
KOMODO_LONGESTCHAIN = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
UniValue addnode(const UniValue& params, bool fHelp)
|
||||
|
||||
@@ -296,8 +296,8 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "blockchain", "paxpending", &paxpending, true },
|
||||
{ "blockchain", "paxprices", &paxprices, true },
|
||||
{ "blockchain", "notaries", ¬aries, true },
|
||||
{ "blockchain", "height_MoM", &height_MoM, true },
|
||||
{ "blockchain", "txMoMproof", &txMoMproof, true },
|
||||
//{ "blockchain", "height_MoM", &height_MoM, true },
|
||||
//{ "blockchain", "txMoMproof", &txMoMproof, true },
|
||||
{ "blockchain", "minerids", &minerids, true },
|
||||
{ "blockchain", "kvsearch", &kvsearch, true },
|
||||
{ "blockchain", "kvupdate", &kvupdate, true },
|
||||
|
||||
@@ -304,8 +304,8 @@ extern UniValue z_validateaddress(const UniValue& params, bool fHelp); // in rpc
|
||||
extern UniValue z_getpaymentdisclosure(const UniValue& params, bool fHelp); // in rpcdisclosure.cpp
|
||||
extern UniValue z_validatepaymentdisclosure(const UniValue ¶ms, bool fHelp); // in rpcdisclosure.cpp
|
||||
|
||||
extern UniValue height_MoM(const UniValue& params, bool fHelp);
|
||||
extern UniValue txMoMproof(const UniValue& params, bool fHelp);
|
||||
//extern UniValue height_MoM(const UniValue& params, bool fHelp);
|
||||
//extern UniValue txMoMproof(const UniValue& params, bool fHelp);
|
||||
extern UniValue notaries(const UniValue& params, bool fHelp);
|
||||
extern UniValue minerids(const UniValue& params, bool fHelp);
|
||||
extern UniValue kvsearch(const UniValue& params, bool fHelp);
|
||||
|
||||
Reference in New Issue
Block a user