28
src/init.cpp
28
src/init.cpp
@@ -641,6 +641,8 @@ static void ZC_LoadParams()
|
||||
/** Initialize bitcoin.
|
||||
* @pre Parameters should be parsed and config file should be read.
|
||||
*/
|
||||
extern int32_t KOMODO_REWIND;
|
||||
|
||||
bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
{
|
||||
// ********************************************************* Step 1: setup
|
||||
@@ -1244,10 +1246,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n",
|
||||
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288));
|
||||
}
|
||||
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
|
||||
GetArg("-checkblocks", 288))) {
|
||||
strLoadError = _("Corrupted block database detected");
|
||||
break;
|
||||
if ( KOMODO_REWIND >= 0 )
|
||||
{
|
||||
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
|
||||
GetArg("-checkblocks", 288))) {
|
||||
strLoadError = _("Corrupted block database detected");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
if (fDebug) LogPrintf("%s\n", e.what());
|
||||
@@ -1456,13 +1461,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
|
||||
if (mapArgs.count("-blocknotify"))
|
||||
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
|
||||
|
||||
uiInterface.InitMessage(_("Activating best chain..."));
|
||||
// scan for better chains in the block chain database, that are not yet connected in the active best chain
|
||||
CValidationState state;
|
||||
if ( !ActivateBestChain(state))
|
||||
strErrors << "Failed to connect best block";
|
||||
|
||||
if ( KOMODO_REWIND >= 0 )
|
||||
{
|
||||
uiInterface.InitMessage(_("Activating best chain..."));
|
||||
// scan for better chains in the block chain database, that are not yet connected in the active best chain
|
||||
CValidationState state;
|
||||
if ( !ActivateBestChain(state))
|
||||
strErrors << "Failed to connect best block";
|
||||
}
|
||||
std::vector<boost::filesystem::path> vImportFiles;
|
||||
if (mapArgs.count("-loadblock"))
|
||||
{
|
||||
|
||||
@@ -545,6 +545,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
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;
|
||||
}
|
||||
if ( NOTARY_PUBKEY33[0] != 0 )
|
||||
printf("(tx.%d: ",i);
|
||||
for (j=0; j<numvouts; j++)
|
||||
{
|
||||
/*if ( i == 0 && j == 0 )
|
||||
@@ -561,6 +563,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
if ( NOTARY_PUBKEY33[0] != 0 )
|
||||
printf("%.8f ",dstr(block.vtx[i].vout[j].nValue));
|
||||
len = block.vtx[i].vout[j].scriptPubKey.size();
|
||||
if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) )
|
||||
{
|
||||
@@ -578,6 +582,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( NOTARY_PUBKEY33[0] != 0 )
|
||||
printf(") ");
|
||||
//printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d notarized.%d special.%d isratification.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts,notarized,specialtx,isratification);
|
||||
if ( notarized != 0 && (notarizedheight != 0 || specialtx != 0) )
|
||||
{
|
||||
@@ -618,6 +624,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( NOTARY_PUBKEY33[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);
|
||||
} else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n");
|
||||
|
||||
@@ -479,7 +479,8 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
}
|
||||
if ( i == 3 )
|
||||
{
|
||||
printf("%s not realtime ht.%d\n",ASSETCHAINS_SYMBOL,ht);
|
||||
if ( tokomodo == 0 )
|
||||
printf("%s not realtime ht.%d\n",ASSETCHAINS_SYMBOL,ht);
|
||||
return(0);
|
||||
}
|
||||
if ( tokomodo == 0 )
|
||||
@@ -575,7 +576,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
||||
PENDING_KOMODO_TX += pax->komodoshis;
|
||||
printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_KOMODO_TX));
|
||||
}
|
||||
if ( numvouts++ >= 1 )
|
||||
if ( numvouts++ >= 64 )
|
||||
break;
|
||||
}
|
||||
if ( numvouts > 1 )
|
||||
@@ -693,6 +694,13 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
||||
offset += komodo_scriptitemlen(&opretlen,&script[offset]);
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||
{
|
||||
extern int32_t KOMODO_REWIND;
|
||||
if ( KOMODO_REWIND < 0 )
|
||||
{
|
||||
fprintf(stderr,"rewind.%d\n",KOMODO_REWIND);
|
||||
sleep(3);
|
||||
KOMODO_REWIND = 0;
|
||||
}
|
||||
for (i=0; i<opretlen; i++)
|
||||
printf("%02x",script[i]);
|
||||
printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X');
|
||||
|
||||
@@ -40,7 +40,7 @@ struct komodo_state KOMODO_STATES[34];
|
||||
#define _COINBASE_MATURITY 100
|
||||
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
|
||||
|
||||
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET;
|
||||
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND;
|
||||
int32_t KOMODO_LASTMINED,prevKOMODO_LASTMINED;
|
||||
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES;
|
||||
uint8_t NOTARY_PUBKEY33[33];
|
||||
|
||||
@@ -1463,10 +1463,10 @@ void komodo_args()
|
||||
KOMODO_PAX = 1;
|
||||
} else KOMODO_PAX = GetArg("-pax",0);
|
||||
name = GetArg("-ac_name","");
|
||||
/*if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 )
|
||||
if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 )
|
||||
{
|
||||
printf("KOMODO_REWIND %d\n",KOMODO_REWIND);
|
||||
}*/
|
||||
}
|
||||
if ( name.c_str()[0] != 0 )
|
||||
{
|
||||
ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10);
|
||||
|
||||
@@ -2768,8 +2768,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
||||
if (!DisconnectTip(state))
|
||||
return false;
|
||||
}
|
||||
/*fprintf(stderr,"chaintip %d vs rewind.%d\n",(int32_t)chainActive.Tip()->nHeight,KOMODO_REWIND);
|
||||
if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND )
|
||||
/*if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND )
|
||||
{
|
||||
fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight);
|
||||
while ( chainActive.Tip()->nHeight > KOMODO_REWIND )
|
||||
|
||||
@@ -663,7 +663,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
if ( i == 33 )
|
||||
externalflag = 1;
|
||||
else externalflag = 0;
|
||||
if ( NOTARY_PUBKEY33[0] != 0 && notaryid < 3 )
|
||||
if ( NOTARY_PUBKEY33[0] != 0 && (notaryid < 3 || notaryid == 34 || notaryid == 51 || notaryid == 52) )
|
||||
{
|
||||
for (i=1; i<66; i++)
|
||||
if ( memcmp(pubkeys[i],pubkeys[0],33) == 0 )
|
||||
@@ -678,19 +678,21 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
}
|
||||
for (j=gpucount=0; j<65; j++)
|
||||
{
|
||||
if ( mids[j] >= 0 )
|
||||
if ( mids[j] >= 0 || notaryid == 34 )
|
||||
fprintf(stderr,"%d ",mids[j]);
|
||||
else fprintf(stderr,"GPU ");
|
||||
if ( mids[j] == -1 )
|
||||
gpucount++;
|
||||
}
|
||||
fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%%\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j);
|
||||
fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%% t.%u\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j,(uint32_t)time(NULL));
|
||||
}
|
||||
for (j=0; j<65; j++)
|
||||
if ( mids[j] == notaryid )
|
||||
break;
|
||||
if ( j == 65 )
|
||||
KOMODO_LASTMINED = 0;
|
||||
} else fprintf(stderr,"no nonz pubkeys\n");
|
||||
if ( (Mining_height >= 235300 && Mining_height < 236000) || (j == 65 && Mining_height > KOMODO_MAYBEMINED+3 && Mining_height > KOMODO_LASTMINED+64) )
|
||||
if ( (Mining_height >= 235300 && Mining_height < 236000) || (j == 65 && Mining_height > KOMODO_MAYBEMINED+1 && Mining_height > KOMODO_LASTMINED+64) )
|
||||
{
|
||||
hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS);
|
||||
fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1);
|
||||
|
||||
Reference in New Issue
Block a user