Add print and possible rejection of blocks based on valid/invalid notarisation!
This commit is contained in:
28
src/komodo.h
28
src/komodo.h
@@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n);
|
int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n);
|
||||||
void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height);
|
void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height);
|
||||||
void komodo_connectblock(CBlockIndex *pindex,CBlock& block);
|
int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block);
|
||||||
|
|
||||||
#include "komodo_structs.h"
|
#include "komodo_structs.h"
|
||||||
#include "komodo_globals.h"
|
#include "komodo_globals.h"
|
||||||
@@ -695,6 +695,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
|||||||
}
|
}
|
||||||
else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 )
|
else if ( ASSETCHAINS_SYMBOL[0] == 0 && matched != 0 && notarized != 0 && validated != 0 )
|
||||||
komodo_rwccdata((char *)"KMD",1,&ccdata,0);
|
komodo_rwccdata((char *)"KMD",1,&ccdata,0);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "NOT VALID NOTARISATION\n");
|
||||||
|
return (-2);
|
||||||
|
}
|
||||||
if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height )
|
if ( matched != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height )
|
||||||
{
|
{
|
||||||
sp->NOTARIZED_HEIGHT = *notarizedheightp;
|
sp->NOTARIZED_HEIGHT = *notarizedheightp;
|
||||||
@@ -708,10 +713,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
|||||||
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);
|
||||||
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 ( 0 && RemoveOrphanedBlocks(*notarizedheightp))
|
|
||||||
{
|
|
||||||
//fprintf(stderr, "Sucessfully removed all known orphaned blocks before height %d\n",*notarizedheightp);
|
|
||||||
}
|
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||||
{
|
{
|
||||||
if ( signedfp == 0 )
|
if ( signedfp == 0 )
|
||||||
@@ -798,7 +800,8 @@ int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys
|
|||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
// int32_t !
|
||||||
|
int32_t komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||||
{
|
{
|
||||||
static int32_t hwmheight;
|
static int32_t hwmheight;
|
||||||
int32_t staked_era; static int32_t lastStakedEra;
|
int32_t staked_era; static int32_t lastStakedEra;
|
||||||
@@ -809,7 +812,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
|||||||
if ( pindex == 0 )
|
if ( pindex == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"komodo_connectblock null pindex\n");
|
fprintf(stderr,"komodo_connectblock null pindex\n");
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
memset(&zero,0,sizeof(zero));
|
memset(&zero,0,sizeof(zero));
|
||||||
komodo_init(pindex->GetHeight());
|
komodo_init(pindex->GetHeight());
|
||||||
@@ -817,7 +820,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
|||||||
if ( (sp= komodo_stateptr(symbol,dest)) == 0 )
|
if ( (sp= komodo_stateptr(symbol,dest)) == 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL);
|
fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL);
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight);
|
//fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight);
|
||||||
if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 )
|
if ( is_STAKED(ASSETCHAINS_SYMBOL) != 0 || IS_STAKED_NOTARY > -1 )
|
||||||
@@ -858,6 +861,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
|||||||
komodo_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0);
|
komodo_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0);
|
||||||
}
|
}
|
||||||
komodo_currentheight_set(chainActive.LastTip()->GetHeight());
|
komodo_currentheight_set(chainActive.LastTip()->GetHeight());
|
||||||
|
int transaction = 0;
|
||||||
if ( pindex != 0 )
|
if ( pindex != 0 )
|
||||||
{
|
{
|
||||||
height = pindex->GetHeight();
|
height = pindex->GetHeight();
|
||||||
@@ -913,6 +917,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
|||||||
fwrite(&signedmask,1,sizeof(signedmask),signedfp);
|
fwrite(&signedmask,1,sizeof(signedmask),signedfp);
|
||||||
fflush(signedfp);
|
fflush(signedfp);
|
||||||
}
|
}
|
||||||
|
transaction = i;
|
||||||
printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts);
|
printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts);
|
||||||
}
|
}
|
||||||
notarized = 1;
|
notarized = 1;
|
||||||
@@ -938,10 +943,13 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
|||||||
if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 )
|
if ( IS_KOMODO_NOTARY != 0 && ASSETCHAINS_SYMBOL[0] == 0 )
|
||||||
printf("%.8f ",dstr(block.vtx[i].vout[j].nValue));
|
printf("%.8f ",dstr(block.vtx[i].vout[j].nValue));
|
||||||
len = block.vtx[i].vout[j].scriptPubKey.size();
|
len = block.vtx[i].vout[j].scriptPubKey.size();
|
||||||
|
|
||||||
if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) )
|
if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) )
|
||||||
{
|
{
|
||||||
memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len);
|
memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len);
|
||||||
notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime());
|
notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,¬arizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized,signedmask,(uint32_t)chainActive.LastTip()->GetBlockTime());
|
||||||
|
if ( notaryid == -2 )
|
||||||
|
return(-1);
|
||||||
if ( 0 && i > 0 )
|
if ( 0 && i > 0 )
|
||||||
{
|
{
|
||||||
for (k=0; k<len; k++)
|
for (k=0; k<len; k++)
|
||||||
@@ -999,6 +1007,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
|||||||
} 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->GetHeight());
|
//fprintf(stderr,"%s end connect.%d\n",ASSETCHAINS_SYMBOL,pindex->GetHeight());
|
||||||
|
if (notarized = 1)
|
||||||
|
return(transaction);
|
||||||
|
else
|
||||||
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3684,7 +3684,11 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||||||
LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001);
|
LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001);
|
||||||
|
|
||||||
//FlushStateToDisk();
|
//FlushStateToDisk();
|
||||||
komodo_connectblock(pindex,*(CBlock *)&block);
|
int tmp = komodo_connectblock(pindex,*(CBlock *)&block); // != block-nVersion-7000000;
|
||||||
|
if ( tmp > 0 )
|
||||||
|
{
|
||||||
|
printf("VALID NOTARISATION connect block.%i tx.%i\n",pindex->GetHeight(),tmp);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user