@@ -5,7 +5,7 @@ RUN apt-get -y update && \
|
|||||||
apt-get -y upgrade && \
|
apt-get -y upgrade && \
|
||||||
apt-get -y install build-essential pkg-config libc6-dev m4 g++-multilib autoconf libtool ncurses-dev \
|
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 \
|
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 && \
|
apt-get clean && \
|
||||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ Dependencies
|
|||||||
|
|
||||||
```
|
```
|
||||||
#The following packages are needed:
|
#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
|
Komodo
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public:
|
|||||||
#include "komodo_cJSON.c"
|
#include "komodo_cJSON.c"
|
||||||
#include "komodo_notary.h"
|
#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\":\"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\":\"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;
|
MoMdepth = 0;
|
||||||
}
|
}
|
||||||
//if ( matched != 0 ) global independent states -> inside *sp
|
//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
|
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));
|
memset(&MoM,0,sizeof(MoM));
|
||||||
MoMdepth = 0;
|
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
|
else if ( func == 'U' ) // deprecated
|
||||||
{
|
{
|
||||||
@@ -349,7 +349,7 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long
|
|||||||
return(-1);
|
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;
|
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];
|
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);
|
//printf("ht.%d func N ht.%d errs.%d\n",height,NOTARIZED_HEIGHT,errs);
|
||||||
if ( sp != 0 )
|
if ( sp != 0 )
|
||||||
{
|
{
|
||||||
if ( sp->MoMdepth > 0 && sp->MoM != zero )
|
//if ( sp->MoMdepth > 0 && sp->MoM != zero )
|
||||||
fputc('M',fp);
|
// fputc('M',fp);
|
||||||
else fputc('N',fp);
|
//else
|
||||||
|
fputc('N',fp);
|
||||||
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
|
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
|
||||||
errs++;
|
errs++;
|
||||||
if ( fwrite(&sp->NOTARIZED_HEIGHT,1,sizeof(sp->NOTARIZED_HEIGHT),fp) != sizeof(sp->NOTARIZED_HEIGHT) )
|
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++;
|
errs++;
|
||||||
if ( fwrite(&sp->NOTARIZED_DESTTXID,1,sizeof(sp->NOTARIZED_DESTTXID),fp) != sizeof(sp->NOTARIZED_DESTTXID) )
|
if ( fwrite(&sp->NOTARIZED_DESTTXID,1,sizeof(sp->NOTARIZED_DESTTXID),fp) != sizeof(sp->NOTARIZED_DESTTXID) )
|
||||||
errs++;
|
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) )
|
if ( fwrite(&sp->MoM,1,sizeof(sp->MoM),fp) != sizeof(sp->MoM) )
|
||||||
errs++;
|
errs++;
|
||||||
if ( fwrite(&sp->MoMdepth,1,sizeof(sp->MoMdepth),fp) != sizeof(sp->MoMdepth) )
|
if ( fwrite(&sp->MoMdepth,1,sizeof(sp->MoMdepth),fp) != sizeof(sp->MoMdepth) )
|
||||||
errs++;
|
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);
|
fflush(fp);
|
||||||
@@ -587,7 +588,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
|||||||
{
|
{
|
||||||
if ( last_rewind != 0 )
|
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);
|
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;
|
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_HEIGHT = *notarizedheightp;
|
||||||
sp->NOTARIZED_HASH = srchash;
|
sp->NOTARIZED_HASH = srchash;
|
||||||
sp->NOTARIZED_DESTTXID = desttxid;
|
sp->NOTARIZED_DESTTXID = desttxid;
|
||||||
memset(&sp->MoM,0,sizeof(sp->MoM));
|
/*memset(&sp->MoM,0,sizeof(sp->MoM));
|
||||||
sp->MoMdepth = 0;
|
sp->MoMdepth = 0;
|
||||||
if ( len+36 <= opretlen )
|
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);
|
//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;
|
len += nameoffset;
|
||||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
//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);
|
// 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 ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||||
{
|
{
|
||||||
if ( signedfp == 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++)
|
//for (i=0; i<opretlen-len; i++)
|
||||||
// printf("%02x",scriptbuf[len+i]);
|
// printf("%02x",scriptbuf[len+i]);
|
||||||
//printf(" Found extradata.[%d] %d - %d\n",opretlen-len,opretlen,len);
|
//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 )
|
} 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')
|
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);
|
return(notaryid);
|
||||||
@@ -728,7 +729,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
|||||||
if ( pindex->nHeight != hwmheight )
|
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);
|
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_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);
|
komodo_currentheight_set(chainActive.Tip()->nHeight);
|
||||||
if ( pindex != 0 )
|
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) )
|
if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries/3) )
|
||||||
{
|
{
|
||||||
memset(&txhash,0,sizeof(txhash));
|
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);
|
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);
|
} 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 )
|
if ( NOTARY_PUBKEY33[0] != 0 && ASSETCHAINS_SYMBOL[0] == 0 )
|
||||||
printf("%s ht.%d\n",ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL,height);
|
printf("%s ht.%d\n",ASSETCHAINS_SYMBOL[0] == 0 ? "KMD" : ASSETCHAINS_SYMBOL,height);
|
||||||
if ( pindex->nHeight == hwmheight )
|
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");
|
} else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n");
|
||||||
//KOMODO_INITDONE = (uint32_t)time(NULL);
|
//KOMODO_INITDONE = (uint32_t)time(NULL);
|
||||||
//fprintf(stderr,"%s end connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight);
|
//fprintf(stderr,"%s end connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight);
|
||||||
|
|||||||
@@ -651,7 +651,6 @@ int32_t komodo_block2height(CBlock *block)
|
|||||||
}
|
}
|
||||||
if ( height != height2 )
|
if ( height != height2 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"block2height height.%d vs height2.%d, match.%d mismatch.%d\n",height,height2,match,mismatch);
|
|
||||||
mismatch++;
|
mismatch++;
|
||||||
if ( height2 >= 0 )
|
if ( height2 >= 0 )
|
||||||
height = height2;
|
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);
|
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;
|
int32_t depth,notarized_ht; uint256 MoM,kmdtxid;
|
||||||
depth = komodo_MoMdata(¬arized_ht,&MoM,&kmdtxid,nHeight,MoMoMp,MoMoMoffsetp,MoMoMdepthp,kmdstartip,kmdendip);
|
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);
|
return(depth);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash)
|
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);
|
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;
|
struct komodo_event_notarized N;
|
||||||
if ( NOTARY_PUBKEY33[0] != 0 && komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid) != 0 )
|
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.blockhash = notarized_hash;
|
||||||
N.desttxid = notarized_desttxid;
|
N.desttxid = notarized_desttxid;
|
||||||
N.notarizedheight = notarizedheight;
|
N.notarizedheight = notarizedheight;
|
||||||
N.MoM = MoM;
|
//N.MoM = MoM;
|
||||||
N.MoMdepth = MoMdepth;
|
//N.MoMdepth = MoMdepth;
|
||||||
strncpy(N.dest,dest,sizeof(N.dest)-1);
|
strncpy(N.dest,dest,sizeof(N.dest)-1);
|
||||||
komodo_eventadd(sp,height,symbol,KOMODO_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N));
|
komodo_eventadd(sp,height,symbol,KOMODO_EVENT_NOTARIZED,(uint8_t *)&N,sizeof(N));
|
||||||
if ( sp != 0 )
|
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"
|
#include "komodo_defs.h"
|
||||||
|
|
||||||
uint32_t komodo_heightstamp(int32_t height);
|
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);
|
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_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);
|
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);
|
char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port);
|
||||||
void komodo_init(int32_t height);
|
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_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||||
int32_t komodo_isrealtime(int32_t *kmdheightp);
|
int32_t komodo_isrealtime(int32_t *kmdheightp);
|
||||||
uint64_t komodo_paxtotal();
|
uint64_t komodo_paxtotal();
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
* *
|
* *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
#include "komodo_defs.h"
|
#include "komodo_defs.h"
|
||||||
|
|
||||||
#include "komodo_cJSON.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)
|
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;
|
int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp;
|
||||||
if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||||
timestamp = komodo_heightstamp(height);
|
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 )
|
if ( did0 == 0 )
|
||||||
{
|
{
|
||||||
n = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0));
|
n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0));
|
||||||
for (i=0; i<n; i++)
|
for (i=0; i<n0; i++)
|
||||||
decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]);
|
decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]);
|
||||||
did0 = 1;
|
did0 = 1;
|
||||||
}
|
}
|
||||||
memcpy(pubkeys,elected_pubkeys0,n * 33);
|
memcpy(pubkeys,elected_pubkeys0,n0 * 33);
|
||||||
//if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
//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 )
|
else //if ( (timestamp != 0 && timestamp <= KOMODO_NOTARIES_TIMESTAMP2) || height <= KOMODO_NOTARIES_HEIGHT2 )
|
||||||
{
|
{
|
||||||
if ( did1 == 0 )
|
if ( did1 == 0 )
|
||||||
{
|
{
|
||||||
n = (int32_t)(sizeof(Notaries_elected1)/sizeof(*Notaries_elected1));
|
n1 = (int32_t)(sizeof(Notaries_elected1)/sizeof(*Notaries_elected1));
|
||||||
for (i=0; i<n; i++)
|
for (i=0; i<n1; i++)
|
||||||
decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]);
|
decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]);
|
||||||
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
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;
|
did1 = 1;
|
||||||
}
|
}
|
||||||
memcpy(pubkeys,elected_pubkeys1,n * 33);
|
memcpy(pubkeys,elected_pubkeys1,n1 * 33);
|
||||||
|
return(n1);
|
||||||
}
|
}
|
||||||
return(n);
|
|
||||||
}
|
}
|
||||||
htind = height / KOMODO_ELECTION_GAP;
|
htind = height / KOMODO_ELECTION_GAP;
|
||||||
if ( htind >= KOMODO_MAXBLOCKS / 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;
|
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 )
|
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(MoMoMp,0,sizeof(*MoMoMp));
|
||||||
memset(kmdtxidp,0,sizeof(*kmdtxidp));
|
memset(kmdtxidp,0,sizeof(*kmdtxidp));
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
|
|
||||||
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp)
|
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);
|
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;
|
struct notarized_checkpoint *np;
|
||||||
if ( notarized_height >= nHeight )
|
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_HEIGHT = np->notarized_height = notarized_height;
|
||||||
sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash;
|
sp->NOTARIZED_HASH = np->notarized_hash = notarized_hash;
|
||||||
sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid;
|
sp->NOTARIZED_DESTTXID = np->notarized_desttxid = notarized_desttxid;
|
||||||
sp->MoM = np->MoM = MoM;
|
//sp->MoM = np->MoM = MoM;
|
||||||
sp->MoMdepth = np->MoMdepth = MoMdepth;
|
//sp->MoMdepth = np->MoMdepth = MoMdepth;
|
||||||
portable_mutex_unlock(&komodo_mutex);
|
portable_mutex_unlock(&komodo_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -540,20 +540,8 @@ void komodo_init(int32_t height)
|
|||||||
//for (i=0; i<sizeof(Minerids); i++)
|
//for (i=0; i<sizeof(Minerids); i++)
|
||||||
// Minerids[i] = -2;
|
// Minerids[i] = -2;
|
||||||
didinit = 1;
|
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)
|
/*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;
|
double KMDBTC,BTCUSD,CNYUSD; uint32_t numpvals,timestamp,pvals[128]; uint256 zero;
|
||||||
numpvals = dpow_readprices(height,pricefeed,×tamp,&KMDBTC,&BTCUSD,&CNYUSD,pvals);
|
numpvals = dpow_readprices(height,pricefeed,×tamp,&KMDBTC,&BTCUSD,&CNYUSD,pvals);
|
||||||
memset(&zero,0,sizeof(zero));
|
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 )
|
if ( 0 )
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i;
|
||||||
|
|||||||
166
src/main.cpp
166
src/main.cpp
@@ -53,7 +53,9 @@ using namespace std;
|
|||||||
|
|
||||||
CCriticalSection cs_main;
|
CCriticalSection cs_main;
|
||||||
extern uint8_t NOTARY_PUBKEY33[33];
|
extern uint8_t NOTARY_PUBKEY33[33];
|
||||||
extern int32_t KOMODO_LOADINGBLOCKS;
|
extern int32_t KOMODO_LOADINGBLOCKS,KOMODO_LONGESTCHAIN;
|
||||||
|
int32_t KOMODO_NEWBLOCKS;
|
||||||
|
void komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block);
|
||||||
|
|
||||||
BlockMap mapBlockIndex;
|
BlockMap mapBlockIndex;
|
||||||
CChain chainActive;
|
CChain chainActive;
|
||||||
@@ -1241,11 +1243,14 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||||||
return error("AcceptToMemoryPool: komodo_validate_interest failed");
|
return error("AcceptToMemoryPool: komodo_validate_interest failed");
|
||||||
}
|
}
|
||||||
if (!CheckTransaction(tx, state, verifier))
|
if (!CheckTransaction(tx, state, verifier))
|
||||||
return error("AcceptToMemoryPool: CheckTransaction failed");
|
{
|
||||||
|
|
||||||
|
return error("AcceptToMemoryPool: CheckTransaction failed");
|
||||||
|
}
|
||||||
// DoS level set to 10 to be more forgiving.
|
// DoS level set to 10 to be more forgiving.
|
||||||
// Check transaction contextually against the set of consensus rules which apply in the next block to be mined.
|
// Check transaction contextually against the set of consensus rules which apply in the next block to be mined.
|
||||||
if (!ContextualCheckTransaction(tx, state, nextBlockHeight, 10)) {
|
if (!ContextualCheckTransaction(tx, state, nextBlockHeight, 10))
|
||||||
|
{
|
||||||
return error("AcceptToMemoryPool: ContextualCheckTransaction failed");
|
return error("AcceptToMemoryPool: ContextualCheckTransaction failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1408,7 +1413,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
|||||||
CAmount txMinFee = GetMinRelayFee(tx, nSize, true);
|
CAmount txMinFee = GetMinRelayFee(tx, nSize, true);
|
||||||
if (fLimitFree && nFees < txMinFee)
|
if (fLimitFree && nFees < txMinFee)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"accept failure.5\n");
|
//fprintf(stderr,"accept failure.5\n");
|
||||||
return state.DoS(0, error("AcceptToMemoryPool: not enough fees %s, %d < %d",hash.ToString(), nFees, txMinFee),REJECT_INSUFFICIENTFEE, "insufficient fee");
|
return state.DoS(0, error("AcceptToMemoryPool: not enough fees %s, %d < %d",hash.ToString(), nFees, txMinFee),REJECT_INSUFFICIENTFEE, "insufficient fee");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1614,7 +1619,7 @@ bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos)
|
|||||||
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus())))
|
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus())))
|
||||||
{
|
{
|
||||||
int32_t i; for (i=0; i<33; i++)
|
int32_t i; for (i=0; i<33; i++)
|
||||||
printf("%02x",pubkey33[i]);
|
fprintf(stderr,"%02x",pubkey33[i]);
|
||||||
fprintf(stderr," warning unexpected diff at ht.%d\n",height);
|
fprintf(stderr," warning unexpected diff at ht.%d\n",height);
|
||||||
|
|
||||||
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
||||||
@@ -1849,7 +1854,7 @@ void Misbehaving(NodeId pnode, int howmuch)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
state->nMisbehavior += howmuch;
|
state->nMisbehavior += howmuch;
|
||||||
int banscore = GetArg("-banscore", 100);
|
int banscore = GetArg("-banscore", 101);
|
||||||
if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore)
|
if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore)
|
||||||
{
|
{
|
||||||
LogPrintf("%s: %s (%d -> %d) BAN THRESHOLD EXCEEDED\n", __func__, state->name, state->nMisbehavior-howmuch, state->nMisbehavior);
|
LogPrintf("%s: %s (%d -> %d) BAN THRESHOLD EXCEEDED\n", __func__, state->name, state->nMisbehavior-howmuch, state->nMisbehavior);
|
||||||
@@ -2424,9 +2429,10 @@ static int64_t nTimeIndex = 0;
|
|||||||
static int64_t nTimeCallbacks = 0;
|
static int64_t nTimeCallbacks = 0;
|
||||||
static int64_t nTimeTotal = 0;
|
static int64_t nTimeTotal = 0;
|
||||||
|
|
||||||
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck)
|
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
|
|
||||||
//fprintf(stderr,"connectblock ht.%d\n",(int32_t)pindex->nHeight);
|
//fprintf(stderr,"connectblock ht.%d\n",(int32_t)pindex->nHeight);
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
bool fExpensiveChecks = true;
|
bool fExpensiveChecks = true;
|
||||||
@@ -2441,7 +2447,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
auto disabledVerifier = libzcash::ProofVerifier::Disabled();
|
auto disabledVerifier = libzcash::ProofVerifier::Disabled();
|
||||||
|
|
||||||
// Check it again to verify JoinSplit proofs, and in case a previous version let a bad block in
|
// Check it again to verify JoinSplit proofs, and in case a previous version let a bad block in
|
||||||
if (!CheckBlock(pindex->nHeight,pindex,block, state, fExpensiveChecks ? verifier : disabledVerifier, !fJustCheck, !fJustCheck))
|
if (!CheckBlock(pindex->nHeight,pindex,block, state, fExpensiveChecks ? verifier : disabledVerifier, fCheckPOW, !fJustCheck)) //!fJustCheck, !fJustCheck))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// verify that the view's current state corresponds to the previous block
|
// verify that the view's current state corresponds to the previous block
|
||||||
@@ -2796,7 +2802,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
|
|||||||
// New best block
|
// New best block
|
||||||
nTimeBestReceived = GetTime();
|
nTimeBestReceived = GetTime();
|
||||||
mempool.AddTransactionsUpdated(1);
|
mempool.AddTransactionsUpdated(1);
|
||||||
|
KOMODO_NEWBLOCKS++;
|
||||||
LogPrintf("%s: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__,
|
LogPrintf("%s: new best=%s height=%d log2_work=%.8g tx=%lu date=%s progress=%f cache=%.1fMiB(%utx)\n", __func__,
|
||||||
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
|
chainActive.Tip()->GetBlockHash().ToString(), chainActive.Height(), log(chainActive.Tip()->nChainWork.getdouble())/log(2.0), (unsigned long)chainActive.Tip()->nChainTx,
|
||||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
|
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", chainActive.Tip()->GetBlockTime()),
|
||||||
@@ -2917,7 +2923,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
|
|||||||
LogPrint("bench", " - Load block from disk: %.2fms [%.2fs]\n", (nTime2 - nTime1) * 0.001, nTimeReadFromDisk * 0.000001);
|
LogPrint("bench", " - Load block from disk: %.2fms [%.2fs]\n", (nTime2 - nTime1) * 0.001, nTimeReadFromDisk * 0.000001);
|
||||||
{
|
{
|
||||||
CCoinsViewCache view(pcoinsTip);
|
CCoinsViewCache view(pcoinsTip);
|
||||||
bool rv = ConnectBlock(*pblock, state, pindexNew, view);
|
bool rv = ConnectBlock(*pblock, state, pindexNew, view, false, true);
|
||||||
GetMainSignals().BlockChecked(*pblock, state);
|
GetMainSignals().BlockChecked(*pblock, state);
|
||||||
if (!rv) {
|
if (!rv) {
|
||||||
if (state.IsInvalid())
|
if (state.IsInvalid())
|
||||||
@@ -3080,21 +3086,21 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
|||||||
}
|
}
|
||||||
if ( KOMODO_REWIND != 0 )
|
if ( KOMODO_REWIND != 0 )
|
||||||
{
|
{
|
||||||
|
CBlockIndex *tipindex;
|
||||||
fprintf(stderr,">>>>>>>>>>> rewind start ht.%d -> KOMODO_REWIND.%d\n",chainActive.Tip()->nHeight,KOMODO_REWIND);
|
fprintf(stderr,">>>>>>>>>>> rewind start ht.%d -> KOMODO_REWIND.%d\n",chainActive.Tip()->nHeight,KOMODO_REWIND);
|
||||||
while ( KOMODO_REWIND > 0 && chainActive.Tip()->nHeight > KOMODO_REWIND )
|
while ( KOMODO_REWIND > 0 && (tipindex= chainActive.Tip()) != 0 && tipindex->nHeight > KOMODO_REWIND )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"%d ",(int32_t)chainActive.Tip()->nHeight);
|
fBlocksDisconnected = true;
|
||||||
|
fprintf(stderr,"%d ",(int32_t)tipindex->nHeight);
|
||||||
|
InvalidateBlock(state,tipindex);
|
||||||
if ( !DisconnectTip(state) )
|
if ( !DisconnectTip(state) )
|
||||||
{
|
|
||||||
InvalidateBlock(state,chainActive.Tip());
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli -ac_name=%s stop\n",KOMODO_REWIND,ASSETCHAINS_SYMBOL);
|
fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli -ac_name=%s stop\n",KOMODO_REWIND,ASSETCHAINS_SYMBOL);
|
||||||
sleep(60);
|
sleep(20);
|
||||||
fprintf(stderr,"resuming normal operations\n");
|
fprintf(stderr,"resuming normal operations\n");
|
||||||
KOMODO_REWIND = 0;
|
KOMODO_REWIND = 0;
|
||||||
return(true);
|
//return(true);
|
||||||
}
|
}
|
||||||
// Build list of new blocks to connect.
|
// Build list of new blocks to connect.
|
||||||
std::vector<CBlockIndex*> vpindexToConnect;
|
std::vector<CBlockIndex*> vpindexToConnect;
|
||||||
@@ -3475,7 +3481,6 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
|
|||||||
|
|
||||||
bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& blockhdr, CValidationState& state, bool fCheckPOW)
|
bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& blockhdr, CValidationState& state, bool fCheckPOW)
|
||||||
{
|
{
|
||||||
uint8_t pubkey33[33];
|
|
||||||
// Check timestamp
|
// Check timestamp
|
||||||
if ( 0 )
|
if ( 0 )
|
||||||
{
|
{
|
||||||
@@ -3504,7 +3509,7 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl
|
|||||||
// return state.DoS(100, error("CheckBlockHeader(): block version too low"),REJECT_INVALID, "version-too-low");
|
// return state.DoS(100, error("CheckBlockHeader(): block version too low"),REJECT_INVALID, "version-too-low");
|
||||||
|
|
||||||
// Check Equihash solution is valid
|
// Check Equihash solution is valid
|
||||||
if ( fCheckPOW && !CheckEquihashSolution(&blockhdr, Params()) )
|
/*if ( fCheckPOW && !CheckEquihashSolution(&blockhdr, Params()) )
|
||||||
return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution");
|
return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution");
|
||||||
|
|
||||||
// Check proof of work matches claimed amount
|
// Check proof of work matches claimed amount
|
||||||
@@ -3516,6 +3521,39 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl
|
|||||||
|
|
||||||
int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime);
|
int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime);
|
||||||
|
|
||||||
|
int32_t komodo_reverify_blockcheck(CValidationState& state,int32_t height,CBlockIndex *pindex)
|
||||||
|
{
|
||||||
|
static int32_t oneshot;
|
||||||
|
CBlockIndex *tipindex; int32_t rewindtarget;
|
||||||
|
if ( KOMODO_REWIND != 0 )
|
||||||
|
oneshot = KOMODO_REWIND;
|
||||||
|
if ( oneshot == 0 && IsInitialBlockDownload() == 0 && (tipindex= chainActive.Tip()) != 0 )
|
||||||
|
{
|
||||||
|
// if 200 blocks behind longestchain and no blocks for 2 hours
|
||||||
|
if ( KOMODO_LONGESTCHAIN > height+200 && KOMODO_NEWBLOCKS == 0 )
|
||||||
|
{
|
||||||
|
if ( GetAdjustedTime() > tipindex->nTime+3600*2 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"possible fork: tip.%d longest.%d newblock.%d lag.%d blocktime.%u\n",tipindex->nHeight,KOMODO_LONGESTCHAIN,height,(int32_t)(GetAdjustedTime() - tipindex->nTime),tipindex->nTime);
|
||||||
|
/*KOMODO_REWIND = tipindex->nHeight - 11;
|
||||||
|
rewindtarget = tipindex->nHeight - 11;
|
||||||
|
fprintf(stderr,"rewindtarget <- %d\n",rewindtarget);
|
||||||
|
oneshot = 1;
|
||||||
|
while ( rewindtarget > 0 && (tipindex= chainActive.Tip()) != 0 && tipindex->nHeight > rewindtarget )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"%d ",(int32_t)tipindex->nHeight);
|
||||||
|
InvalidateBlock(state,tipindex);
|
||||||
|
if ( !DisconnectTip(state) )
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
tipindex = chainActive.Tip();
|
||||||
|
fprintf(stderr,"rewind done to %d\n",tipindex!=0?tipindex->nHeight:-1);*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidationState& state,
|
bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidationState& state,
|
||||||
libzcash::ProofVerifier& verifier,
|
libzcash::ProofVerifier& verifier,
|
||||||
bool fCheckPOW, bool fCheckMerkleRoot)
|
bool fCheckPOW, bool fCheckMerkleRoot)
|
||||||
@@ -3526,11 +3564,15 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat
|
|||||||
// Check that the header is valid (particularly PoW). This is mostly
|
// Check that the header is valid (particularly PoW). This is mostly
|
||||||
// redundant with the call in AcceptBlockHeader.
|
// redundant with the call in AcceptBlockHeader.
|
||||||
if (!CheckBlockHeader(height,pindex,block,state,fCheckPOW))
|
if (!CheckBlockHeader(height,pindex,block,state,fCheckPOW))
|
||||||
|
{
|
||||||
|
fprintf(stderr,"checkblockheader error PoW.%d\n",fCheckPOW);
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) )
|
||||||
|
return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution");
|
||||||
komodo_block2pubkey33(pubkey33,(CBlock *)&block);
|
komodo_block2pubkey33(pubkey33,(CBlock *)&block);
|
||||||
if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus()) )
|
if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus()) )
|
||||||
return state.DoS(50, error("CheckBlock(): proof of work failed"),REJECT_INVALID, "high-hash");
|
return state.DoS(1, error("CheckBlock(): proof of work failed"),REJECT_INVALID, "high-hash");
|
||||||
|
|
||||||
// Check the merkle root.
|
// Check the merkle root.
|
||||||
if (fCheckMerkleRoot) {
|
if (fCheckMerkleRoot) {
|
||||||
bool mutated;
|
bool mutated;
|
||||||
@@ -3585,7 +3627,7 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat
|
|||||||
//if ( komodo_check_deposit(ASSETCHAINS_SYMBOL[0] == 0 ? height : pindex != 0 ? (int32_t)pindex->nHeight : chainActive.Tip()->nHeight+1,block,pindex==0||pindex->pprev==0?0:pindex->pprev->nTime) < 0 )
|
//if ( komodo_check_deposit(ASSETCHAINS_SYMBOL[0] == 0 ? height : pindex != 0 ? (int32_t)pindex->nHeight : chainActive.Tip()->nHeight+1,block,pindex==0||pindex->pprev==0?0:pindex->pprev->nTime) < 0 )
|
||||||
{
|
{
|
||||||
static uint32_t counter;
|
static uint32_t counter;
|
||||||
if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 )
|
//if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 )
|
||||||
fprintf(stderr,"check deposit rejection\n");
|
fprintf(stderr,"check deposit rejection\n");
|
||||||
return(false);
|
return(false);
|
||||||
}
|
}
|
||||||
@@ -3622,18 +3664,19 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
|
|||||||
// Check that the block chain matches the known block chain up to a checkpoint
|
// Check that the block chain matches the known block chain up to a checkpoint
|
||||||
if (!Checkpoints::CheckBlock(chainParams.Checkpoints(), nHeight, hash))
|
if (!Checkpoints::CheckBlock(chainParams.Checkpoints(), nHeight, hash))
|
||||||
{
|
{
|
||||||
CBlockIndex *heightblock = chainActive[nHeight];
|
/*CBlockIndex *heightblock = chainActive[nHeight];
|
||||||
if ( heightblock != 0 && heightblock->GetBlockHash() == hash )
|
if ( heightblock != 0 && heightblock->GetBlockHash() == hash )
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"got a pre notarization block that matches height.%d\n",(int32_t)nHeight);
|
//fprintf(stderr,"got a pre notarization block that matches height.%d\n",(int32_t)nHeight);
|
||||||
return true;
|
return true;
|
||||||
} return state.DoS(100, error("%s: rejected by checkpoint lock-in at %d", __func__, nHeight),REJECT_CHECKPOINT, "checkpoint mismatch");
|
}*/
|
||||||
|
return state.DoS(100, error("%s: rejected by checkpoint lock-in at %d", __func__, nHeight),REJECT_CHECKPOINT, "checkpoint mismatch");
|
||||||
}
|
}
|
||||||
// Don't accept any forks from the main chain prior to last checkpoint
|
// Don't accept any forks from the main chain prior to last checkpoint
|
||||||
CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints());
|
CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(chainParams.Checkpoints());
|
||||||
int32_t notarized_height;
|
int32_t notarized_height;
|
||||||
if (pcheckpoint && nHeight > 1 && nHeight < pcheckpoint->nHeight )
|
if (pcheckpoint && nHeight > 1 && nHeight < pcheckpoint->nHeight )
|
||||||
return state.DoS(100, error("%s: forked chain older than last checkpoint (height %d) vs %d", __func__, nHeight,pcheckpoint->nHeight));
|
return state.DoS(1, error("%s: forked chain older than last checkpoint (height %d) vs %d", __func__, nHeight,pcheckpoint->nHeight));
|
||||||
else if ( komodo_checkpoint(¬arized_height,nHeight,hash) < 0 )
|
else if ( komodo_checkpoint(¬arized_height,nHeight,hash) < 0 )
|
||||||
{
|
{
|
||||||
CBlockIndex *heightblock = chainActive[nHeight];
|
CBlockIndex *heightblock = chainActive[nHeight];
|
||||||
@@ -3641,7 +3684,7 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
|
|||||||
{
|
{
|
||||||
//fprintf(stderr,"got a pre notarization block that matches height.%d\n",(int32_t)nHeight);
|
//fprintf(stderr,"got a pre notarization block that matches height.%d\n",(int32_t)nHeight);
|
||||||
return true;
|
return true;
|
||||||
} else return state.DoS(100, error("%s: forked chain %d older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height));
|
} else return state.DoS(1, error("%s: forked chain %d older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Reject block.nVersion < 4 blocks
|
// Reject block.nVersion < 4 blocks
|
||||||
@@ -3705,9 +3748,10 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
|
|||||||
*ppindex = pindex;
|
*ppindex = pindex;
|
||||||
if ( pindex != 0 && pindex->nStatus & BLOCK_FAILED_MASK )
|
if ( pindex != 0 && pindex->nStatus & BLOCK_FAILED_MASK )
|
||||||
return state.Invalid(error("%s: block is marked invalid", __func__), 0, "duplicate");
|
return state.Invalid(error("%s: block is marked invalid", __func__), 0, "duplicate");
|
||||||
|
#ifdef DEXcode
|
||||||
if ( pindex != 0 && IsInitialBlockDownload() == 0 ) // jl777 debug test
|
if ( pindex != 0 && IsInitialBlockDownload() == 0 ) // jl777 debug test
|
||||||
{
|
{
|
||||||
if (!CheckBlockHeader(pindex->nHeight,pindex, block, state))
|
if (!CheckBlockHeader(pindex->nHeight,pindex, block, state,0))
|
||||||
{
|
{
|
||||||
pindex->nStatus |= BLOCK_FAILED_MASK;
|
pindex->nStatus |= BLOCK_FAILED_MASK;
|
||||||
fprintf(stderr,"known block failing CheckBlockHeader %d\n",(int32_t)pindex->nHeight);
|
fprintf(stderr,"known block failing CheckBlockHeader %d\n",(int32_t)pindex->nHeight);
|
||||||
@@ -3734,17 +3778,22 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
|
|||||||
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
||||||
{
|
{
|
||||||
pindex->nStatus |= BLOCK_FAILED_MASK;
|
pindex->nStatus |= BLOCK_FAILED_MASK;
|
||||||
fprintf(stderr,"known block.%d failing ContextualCheckBlockHeader\n",(int32_t)pindex->nHeight);
|
//fprintf(stderr,"known block.%d failing ContextualCheckBlockHeader\n",(int32_t)pindex->nHeight);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ( *ppindex == 0 )
|
||||||
|
fprintf(stderr,"unexpected null *ppindex\n");
|
||||||
|
#endif
|
||||||
|
if ( pindex != 0 )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckBlockHeader(*ppindex!=0?(*ppindex)->nHeight:0,*ppindex, block, state))
|
if (!CheckBlockHeader(*ppindex!=0?(*ppindex)->nHeight:0,*ppindex, block, state,0))
|
||||||
|
{
|
||||||
|
fprintf(stderr,"CheckBlockHeader failed\n");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
// Get prev block index
|
// Get prev block index
|
||||||
CBlockIndex* pindexPrev = NULL;
|
CBlockIndex* pindexPrev = NULL;
|
||||||
if (hash != chainparams.GetConsensus().hashGenesisBlock) {
|
if (hash != chainparams.GetConsensus().hashGenesisBlock) {
|
||||||
@@ -3758,9 +3807,15 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
|
|||||||
return state.DoS(100, error("%s: prev block invalid", __func__), REJECT_INVALID, "bad-prevblk");
|
return state.DoS(100, error("%s: prev block invalid", __func__), REJECT_INVALID, "bad-prevblk");
|
||||||
}
|
}
|
||||||
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
if (!ContextualCheckBlockHeader(block, state, pindexPrev))
|
||||||
|
{
|
||||||
|
//fprintf(stderr,"ContextualCheckBlockHeader failed\n");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
if (pindex == NULL)
|
if (pindex == NULL)
|
||||||
pindex = AddToBlockIndex(block);
|
{
|
||||||
|
if ( (pindex= AddToBlockIndex(block)) == 0 )
|
||||||
|
fprintf(stderr,"couldnt add to block index\n");
|
||||||
|
}
|
||||||
if (ppindex)
|
if (ppindex)
|
||||||
*ppindex = pindex;
|
*ppindex = pindex;
|
||||||
return true;
|
return true;
|
||||||
@@ -3773,12 +3828,16 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
|
|||||||
|
|
||||||
CBlockIndex *&pindex = *ppindex;
|
CBlockIndex *&pindex = *ppindex;
|
||||||
if (!AcceptBlockHeader(block, state, &pindex))
|
if (!AcceptBlockHeader(block, state, &pindex))
|
||||||
return false;
|
|
||||||
if ( pindex == 0 )
|
|
||||||
{
|
{
|
||||||
fprintf(stderr,"AcceptBlock error null pindex\n");
|
fprintf(stderr,"AcceptBlockHeader rejected\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if ( pindex == 0 )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"unexpected AcceptBlock error null pindex\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//fprintf(stderr,"acceptblockheader passed\n");
|
||||||
// Try to process all requested blocks that we don't have, but only
|
// Try to process all requested blocks that we don't have, but only
|
||||||
// process an unrequested block if it's new and has enough work to
|
// process an unrequested block if it's new and has enough work to
|
||||||
// advance our tip, and isn't too many blocks ahead.
|
// advance our tip, and isn't too many blocks ahead.
|
||||||
@@ -3802,11 +3861,13 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
|
|||||||
|
|
||||||
// See method docstring for why this is always disabled
|
// See method docstring for why this is always disabled
|
||||||
auto verifier = libzcash::ProofVerifier::Disabled();
|
auto verifier = libzcash::ProofVerifier::Disabled();
|
||||||
if ((!CheckBlock(pindex->nHeight,pindex,block, state, verifier)) || !ContextualCheckBlock(block, state, pindex->pprev)) {
|
if ((!CheckBlock(pindex->nHeight,pindex,block, state, verifier,0)) || !ContextualCheckBlock(block, state, pindex->pprev))
|
||||||
|
{
|
||||||
if (state.IsInvalid() && !state.CorruptionPossible()) {
|
if (state.IsInvalid() && !state.CorruptionPossible()) {
|
||||||
pindex->nStatus |= BLOCK_FAILED_VALID;
|
pindex->nStatus |= BLOCK_FAILED_VALID;
|
||||||
setDirtyBlockIndex.insert(pindex);
|
setDirtyBlockIndex.insert(pindex);
|
||||||
}
|
}
|
||||||
|
fprintf(stderr,"CheckBlock or ContextualCheckBlock failed\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3857,15 +3918,18 @@ bool ProcessNewBlock(int32_t height,CValidationState &state, CNode* pfrom, CBloc
|
|||||||
if ( chainActive.Tip() != 0 )
|
if ( chainActive.Tip() != 0 )
|
||||||
komodo_currentheight_set(chainActive.Tip()->nHeight);
|
komodo_currentheight_set(chainActive.Tip()->nHeight);
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||||
checked = CheckBlock(height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier);
|
checked = CheckBlock(height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier,0);
|
||||||
else checked = CheckBlock(height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier);
|
else checked = CheckBlock(height!=0?height:komodo_block2height(pblock),0,*pblock, state, verifier,0);
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
bool fRequested = MarkBlockAsReceived(pblock->GetHash());
|
bool fRequested = MarkBlockAsReceived(pblock->GetHash());
|
||||||
fRequested |= fForceProcessing;
|
fRequested |= fForceProcessing;
|
||||||
if (!checked) {
|
if (!checked)
|
||||||
|
{
|
||||||
if ( pfrom != 0 )
|
if ( pfrom != 0 )
|
||||||
|
{
|
||||||
Misbehaving(pfrom->GetId(), 1);
|
Misbehaving(pfrom->GetId(), 1);
|
||||||
|
}
|
||||||
return error("%s: CheckBlock FAILED", __func__);
|
return error("%s: CheckBlock FAILED", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3906,7 +3970,7 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
|
|||||||
}
|
}
|
||||||
if (!CheckBlock(indexDummy.nHeight,0,block, state, verifier, fCheckPOW, fCheckMerkleRoot))
|
if (!CheckBlock(indexDummy.nHeight,0,block, state, verifier, fCheckPOW, fCheckMerkleRoot))
|
||||||
{
|
{
|
||||||
//fprintf(stderr,"TestBlockValidity failure B\n");
|
fprintf(stderr,"TestBlockValidity failure B\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ContextualCheckBlock(block, state, pindexPrev))
|
if (!ContextualCheckBlock(block, state, pindexPrev))
|
||||||
@@ -3914,7 +3978,7 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
|
|||||||
fprintf(stderr,"TestBlockValidity failure C\n");
|
fprintf(stderr,"TestBlockValidity failure C\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!ConnectBlock(block, state, &indexDummy, viewNew, true))
|
if (!ConnectBlock(block, state, &indexDummy, viewNew, true,fCheckPOW))
|
||||||
{
|
{
|
||||||
fprintf(stderr,"TestBlockValidity failure D\n");
|
fprintf(stderr,"TestBlockValidity failure D\n");
|
||||||
return false;
|
return false;
|
||||||
@@ -4040,6 +4104,7 @@ bool CheckDiskSpace(uint64_t nAdditionalBytes)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
|
FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
|
||||||
{
|
{
|
||||||
static int32_t didinit[1000]; long fsize,fpos; int32_t incr = 16*1024*1024;
|
static int32_t didinit[1000]; long fsize,fpos; int32_t incr = 16*1024*1024;
|
||||||
@@ -4117,6 +4182,8 @@ CBlockIndex * InsertBlockIndex(uint256 hash)
|
|||||||
return pindexNew;
|
return pindexNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void komodo_pindex_init(CBlockIndex *pindex,int32_t height);
|
||||||
|
|
||||||
bool static LoadBlockIndexDB()
|
bool static LoadBlockIndexDB()
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams = Params();
|
||||||
@@ -4132,6 +4199,7 @@ bool static LoadBlockIndexDB()
|
|||||||
{
|
{
|
||||||
CBlockIndex* pindex = item.second;
|
CBlockIndex* pindex = item.second;
|
||||||
vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex));
|
vSortedByHeight.push_back(make_pair(pindex->nHeight, pindex));
|
||||||
|
//komodo_pindex_init(pindex,(int32_t)pindex->nHeight);
|
||||||
}
|
}
|
||||||
sort(vSortedByHeight.begin(), vSortedByHeight.end());
|
sort(vSortedByHeight.begin(), vSortedByHeight.end());
|
||||||
BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight)
|
BOOST_FOREACH(const PAIRTYPE(int, CBlockIndex*)& item, vSortedByHeight)
|
||||||
@@ -4180,6 +4248,7 @@ bool static LoadBlockIndexDB()
|
|||||||
pindex->BuildSkip();
|
pindex->BuildSkip();
|
||||||
if (pindex->IsValid(BLOCK_VALID_TREE) && (pindexBestHeader == NULL || CBlockIndexWorkComparator()(pindexBestHeader, pindex)))
|
if (pindex->IsValid(BLOCK_VALID_TREE) && (pindexBestHeader == NULL || CBlockIndexWorkComparator()(pindexBestHeader, pindex)))
|
||||||
pindexBestHeader = pindex;
|
pindexBestHeader = pindex;
|
||||||
|
//komodo_pindex_init(pindex,(int32_t)pindex->nHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load block file info
|
// Load block file info
|
||||||
@@ -4208,6 +4277,7 @@ bool static LoadBlockIndexDB()
|
|||||||
if (pindex->nStatus & BLOCK_HAVE_DATA) {
|
if (pindex->nStatus & BLOCK_HAVE_DATA) {
|
||||||
setBlkDataFiles.insert(pindex->nFile);
|
setBlkDataFiles.insert(pindex->nFile);
|
||||||
}
|
}
|
||||||
|
//komodo_pindex_init(pindex,(int32_t)pindex->nHeight);
|
||||||
}
|
}
|
||||||
for (std::set<int>::iterator it = setBlkDataFiles.begin(); it != setBlkDataFiles.end(); it++)
|
for (std::set<int>::iterator it = setBlkDataFiles.begin(); it != setBlkDataFiles.end(); it++)
|
||||||
{
|
{
|
||||||
@@ -4243,6 +4313,7 @@ bool static LoadBlockIndexDB()
|
|||||||
if (pindex->pprev) {
|
if (pindex->pprev) {
|
||||||
pindex->pprev->hashAnchorEnd = pindex->hashAnchor;
|
pindex->pprev->hashAnchorEnd = pindex->hashAnchor;
|
||||||
}
|
}
|
||||||
|
//komodo_pindex_init(pindex,(int32_t)pindex->nHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load pointer to end of best chain
|
// Load pointer to end of best chain
|
||||||
@@ -4306,7 +4377,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
|
|||||||
if (!ReadBlockFromDisk(block, pindex))
|
if (!ReadBlockFromDisk(block, pindex))
|
||||||
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||||
// check level 1: verify block validity
|
// check level 1: verify block validity
|
||||||
if (nCheckLevel >= 1 && !CheckBlock(pindex->nHeight,pindex,block, state, verifier))
|
if (nCheckLevel >= 1 && !CheckBlock(pindex->nHeight,pindex,block, state, verifier,0))
|
||||||
return error("VerifyDB(): *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
return error("VerifyDB(): *** found bad block at %d, hash=%s\n", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||||
// check level 2: verify undo validity
|
// check level 2: verify undo validity
|
||||||
if (nCheckLevel >= 2 && pindex) {
|
if (nCheckLevel >= 2 && pindex) {
|
||||||
@@ -4345,7 +4416,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
|
|||||||
CBlock block;
|
CBlock block;
|
||||||
if (!ReadBlockFromDisk(block, pindex))
|
if (!ReadBlockFromDisk(block, pindex))
|
||||||
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||||
if (!ConnectBlock(block, state, pindex, coins))
|
if (!ConnectBlock(block, state, pindex, coins,false, true))
|
||||||
return error("VerifyDB(): *** found unconnectable block at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
return error("VerifyDB(): *** found unconnectable block at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4458,6 +4529,12 @@ bool RewindBlockIndex(const CChainParams& params)
|
|||||||
pindexIter->nSequenceId = 0;
|
pindexIter->nSequenceId = 0;
|
||||||
// Make sure it gets written
|
// Make sure it gets written
|
||||||
setDirtyBlockIndex.insert(pindexIter);
|
setDirtyBlockIndex.insert(pindexIter);
|
||||||
|
if (pindexIter == pindexBestInvalid)
|
||||||
|
{
|
||||||
|
//fprintf(stderr,"Reset invalid block marker if it was pointing to this block\n");
|
||||||
|
pindexBestInvalid = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Update indices
|
// Update indices
|
||||||
setBlockIndexCandidates.erase(pindexIter);
|
setBlockIndexCandidates.erase(pindexIter);
|
||||||
auto ret = mapBlocksUnlinked.equal_range(pindexIter->pprev);
|
auto ret = mapBlocksUnlinked.equal_range(pindexIter->pprev);
|
||||||
@@ -5699,7 +5776,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
|||||||
}
|
}
|
||||||
if (!AcceptBlockHeader(header, state, &pindexLast)) {
|
if (!AcceptBlockHeader(header, state, &pindexLast)) {
|
||||||
int nDoS;
|
int nDoS;
|
||||||
if (state.IsInvalid(nDoS)) {
|
if (state.IsInvalid(nDoS))
|
||||||
|
{
|
||||||
if (nDoS > 0)
|
if (nDoS > 0)
|
||||||
Misbehaving(pfrom->GetId(), nDoS/nDoS);
|
Misbehaving(pfrom->GetId(), nDoS/nDoS);
|
||||||
return error("invalid header received");
|
return error("invalid header received");
|
||||||
|
|||||||
@@ -447,7 +447,7 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex);
|
|||||||
bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& coins, bool* pfClean = NULL);
|
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 */
|
/** 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 */
|
/** Context-independent validity checks */
|
||||||
bool CheckBlockHeader(int32_t height,CBlockIndex *pindex,const CBlockHeader& block, CValidationState& state, bool fCheckPOW = true);
|
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];
|
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33];
|
||||||
uint32_t Mining_start,Mining_height;
|
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_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);
|
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize);
|
||||||
uint64_t komodo_paxtotal();
|
uint64_t komodo_paxtotal();
|
||||||
int32_t komodo_baseid(char *origbase);
|
int32_t komodo_baseid(char *origbase);
|
||||||
@@ -385,7 +386,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
|||||||
nLastBlockTx = nBlockTx;
|
nLastBlockTx = nBlockTx;
|
||||||
nLastBlockSize = nBlockSize;
|
nLastBlockSize = nBlockSize;
|
||||||
blocktime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
blocktime = std::max(pindexPrev->GetMedianTimePast()+1, GetAdjustedTime());
|
||||||
pblock->nTime = blocktime + 1;
|
//pblock->nTime = blocktime + 1;
|
||||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||||
//LogPrintf("CreateNewBlock(): total size %u blocktime.%u nBits.%08x\n", nBlockSize,blocktime,pblock->nBits);
|
//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 )
|
if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_STAKED != 0 && NOTARY_PUBKEY33[0] != 0 )
|
||||||
@@ -479,8 +480,11 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
|||||||
// Fill in header
|
// Fill in header
|
||||||
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
|
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
|
||||||
pblock->hashReserved = uint256();
|
pblock->hashReserved = uint256();
|
||||||
//UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
|
if ( ASSETCHAINS_SYMBOL[0] == 0 || ASSETCHAINS_STAKED == 0 || NOTARY_PUBKEY33[0] == 0 )
|
||||||
//pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
{
|
||||||
|
UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
|
||||||
|
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
|
||||||
|
}
|
||||||
pblock->nSolution.clear();
|
pblock->nSolution.clear();
|
||||||
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
|
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
|
||||||
|
|
||||||
@@ -488,8 +492,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
|||||||
if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false))
|
if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false))
|
||||||
{
|
{
|
||||||
static uint32_t counter;
|
static uint32_t counter;
|
||||||
if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 )
|
//if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 )
|
||||||
fprintf(stderr,"warning: testblockvalidity failed\n");
|
fprintf(stderr,"warning: miner testblockvalidity failed\n");
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -914,6 +918,12 @@ void static BitcoinMiner()
|
|||||||
// fprintf(stderr," missed target\n");
|
// fprintf(stderr," missed target\n");
|
||||||
return false;
|
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 ( ASSETCHAINS_STAKED == 0 )
|
||||||
{
|
{
|
||||||
if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay )
|
if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay )
|
||||||
@@ -931,12 +941,6 @@ void static BitcoinMiner()
|
|||||||
}
|
}
|
||||||
else
|
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 )
|
if ( NOTARY_PUBKEY33[0] != 0 )
|
||||||
{
|
{
|
||||||
printf("need to wait %d seconds to submit\n",(int32_t)(pblock->nTime - GetAdjustedTime()));
|
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;
|
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_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_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();
|
int32_t komodo_currentheight();
|
||||||
|
|||||||
@@ -589,6 +589,7 @@ UniValue kvsearch(const UniValue& params, bool fHelp)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
UniValue height_MoM(const UniValue& params, bool fHelp)
|
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);
|
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);
|
ssProof << MoMProof(nIndex, branch, notarisationHash);
|
||||||
return HexStr(ssProof.begin(), ssProof.end());
|
return HexStr(ssProof.begin(), ssProof.end());
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
UniValue minerids(const UniValue& params, bool fHelp)
|
UniValue minerids(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
@@ -732,7 +734,7 @@ UniValue minerids(const UniValue& params, bool fHelp)
|
|||||||
if ( pblockindex != 0 )
|
if ( pblockindex != 0 )
|
||||||
timestamp = pblockindex->GetBlockTime();
|
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));
|
memset(tally,0,sizeof(tally));
|
||||||
numnotaries = komodo_notaries(pubkeys,height,timestamp);
|
numnotaries = komodo_notaries(pubkeys,height,timestamp);
|
||||||
|
|||||||
@@ -125,8 +125,8 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
|||||||
{ "paxprices", 3 },
|
{ "paxprices", 3 },
|
||||||
{ "paxpending", 0 },
|
{ "paxpending", 0 },
|
||||||
{ "notaries", 2 },
|
{ "notaries", 2 },
|
||||||
{ "height_MoM", 1 },
|
//{ "height_MoM", 1 },
|
||||||
{ "txMoMproof", 1 },
|
//{ "txMoMproof", 1 },
|
||||||
{ "minerids", 1 },
|
{ "minerids", 1 },
|
||||||
{ "kvsearch", 1 },
|
{ "kvsearch", 1 },
|
||||||
{ "kvupdate", 4 },
|
{ "kvupdate", 4 },
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE;
|
|||||||
extern char ASSETCHAINS_SYMBOL[];
|
extern char ASSETCHAINS_SYMBOL[];
|
||||||
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
|
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
|
||||||
#define KOMODO_VERSION "0.1.1"
|
#define KOMODO_VERSION "0.1.1"
|
||||||
|
uint32_t komodo_chainactive_timestamp();
|
||||||
|
|
||||||
UniValue getinfo(const UniValue& params, bool fHelp)
|
UniValue getinfo(const UniValue& params, bool fHelp)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t KOMODO_LONGESTCHAIN;
|
||||||
int32_t komodo_longestchain()
|
int32_t komodo_longestchain()
|
||||||
{
|
{
|
||||||
int32_t ht,n=0,num=0,maxheight=0,height = 0;
|
int32_t ht,n=0,num=0,maxheight=0,height = 0;
|
||||||
@@ -191,8 +192,12 @@ int32_t komodo_longestchain()
|
|||||||
height = ht;
|
height = ht;
|
||||||
}
|
}
|
||||||
if ( num > (n >> 1) )
|
if ( num > (n >> 1) )
|
||||||
|
{
|
||||||
|
KOMODO_LONGESTCHAIN = height;
|
||||||
return(height);
|
return(height);
|
||||||
else return(0);
|
}
|
||||||
|
KOMODO_LONGESTCHAIN = 0;
|
||||||
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
UniValue addnode(const UniValue& params, bool fHelp)
|
UniValue addnode(const UniValue& params, bool fHelp)
|
||||||
|
|||||||
@@ -296,8 +296,8 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "blockchain", "paxpending", &paxpending, true },
|
{ "blockchain", "paxpending", &paxpending, true },
|
||||||
{ "blockchain", "paxprices", &paxprices, true },
|
{ "blockchain", "paxprices", &paxprices, true },
|
||||||
{ "blockchain", "notaries", ¬aries, true },
|
{ "blockchain", "notaries", ¬aries, true },
|
||||||
{ "blockchain", "height_MoM", &height_MoM, true },
|
//{ "blockchain", "height_MoM", &height_MoM, true },
|
||||||
{ "blockchain", "txMoMproof", &txMoMproof, true },
|
//{ "blockchain", "txMoMproof", &txMoMproof, true },
|
||||||
{ "blockchain", "minerids", &minerids, true },
|
{ "blockchain", "minerids", &minerids, true },
|
||||||
{ "blockchain", "kvsearch", &kvsearch, true },
|
{ "blockchain", "kvsearch", &kvsearch, true },
|
||||||
{ "blockchain", "kvupdate", &kvupdate, 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_getpaymentdisclosure(const UniValue& params, bool fHelp); // in rpcdisclosure.cpp
|
||||||
extern UniValue z_validatepaymentdisclosure(const UniValue ¶ms, 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 height_MoM(const UniValue& params, bool fHelp);
|
||||||
extern UniValue txMoMproof(const UniValue& params, bool fHelp);
|
//extern UniValue txMoMproof(const UniValue& params, bool fHelp);
|
||||||
extern UniValue notaries(const UniValue& params, bool fHelp);
|
extern UniValue notaries(const UniValue& params, bool fHelp);
|
||||||
extern UniValue minerids(const UniValue& params, bool fHelp);
|
extern UniValue minerids(const UniValue& params, bool fHelp);
|
||||||
extern UniValue kvsearch(const UniValue& params, bool fHelp);
|
extern UniValue kvsearch(const UniValue& params, bool fHelp);
|
||||||
|
|||||||
Reference in New Issue
Block a user