Merge pull request #318 from jl777/dev

Dev
This commit is contained in:
jl777
2017-03-19 00:37:04 +02:00
committed by GitHub
7 changed files with 45 additions and 22 deletions

View File

@@ -641,6 +641,8 @@ static void ZC_LoadParams()
/** Initialize bitcoin. /** Initialize bitcoin.
* @pre Parameters should be parsed and config file should be read. * @pre Parameters should be parsed and config file should be read.
*/ */
extern int32_t KOMODO_REWIND;
bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
{ {
// ********************************************************* Step 1: setup // ********************************************************* 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", LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n",
MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288)); MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288));
} }
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3), if ( KOMODO_REWIND >= 0 )
GetArg("-checkblocks", 288))) { {
strLoadError = _("Corrupted block database detected"); if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
break; GetArg("-checkblocks", 288))) {
strLoadError = _("Corrupted block database detected");
break;
}
} }
} catch (const std::exception& e) { } catch (const std::exception& e) {
if (fDebug) LogPrintf("%s\n", e.what()); if (fDebug) LogPrintf("%s\n", e.what());
@@ -1456,13 +1461,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
if (mapArgs.count("-blocknotify")) if (mapArgs.count("-blocknotify"))
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback); uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
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 uiInterface.InitMessage(_("Activating best chain..."));
CValidationState state; // scan for better chains in the block chain database, that are not yet connected in the active best chain
if ( !ActivateBestChain(state)) CValidationState state;
strErrors << "Failed to connect best block"; if ( !ActivateBestChain(state))
strErrors << "Failed to connect best block";
}
std::vector<boost::filesystem::path> vImportFiles; std::vector<boost::filesystem::path> vImportFiles;
if (mapArgs.count("-loadblock")) if (mapArgs.count("-loadblock"))
{ {

View File

@@ -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); 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;
} }
if ( NOTARY_PUBKEY33[0] != 0 )
printf("(tx.%d: ",i);
for (j=0; j<numvouts; j++) for (j=0; j<numvouts; j++)
{ {
/*if ( i == 0 && j == 0 ) /*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(); len = block.vtx[i].vout[j].scriptPubKey.size();
if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) ) 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); //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) ) 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 ) if ( pindex->nHeight == hwmheight )
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0); 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"); } else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n");

View File

@@ -479,7 +479,8 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
} }
if ( i == 3 ) 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); return(0);
} }
if ( tokomodo == 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; 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)); 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; break;
} }
if ( numvouts > 1 ) 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]); offset += komodo_scriptitemlen(&opretlen,&script[offset]);
if ( ASSETCHAINS_SYMBOL[0] == 0 ) 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++) for (i=0; i<opretlen; i++)
printf("%02x",script[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'); printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X');

View File

@@ -40,7 +40,7 @@ struct komodo_state KOMODO_STATES[34];
#define _COINBASE_MATURITY 100 #define _COINBASE_MATURITY 100
int COINBASE_MATURITY = _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; int32_t KOMODO_LASTMINED,prevKOMODO_LASTMINED;
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES;
uint8_t NOTARY_PUBKEY33[33]; uint8_t NOTARY_PUBKEY33[33];

View File

@@ -1463,10 +1463,10 @@ void komodo_args()
KOMODO_PAX = 1; KOMODO_PAX = 1;
} else KOMODO_PAX = GetArg("-pax",0); } else KOMODO_PAX = GetArg("-pax",0);
name = GetArg("-ac_name",""); 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); printf("KOMODO_REWIND %d\n",KOMODO_REWIND);
}*/ }
if ( name.c_str()[0] != 0 ) if ( name.c_str()[0] != 0 )
{ {
ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10);

View File

@@ -2768,8 +2768,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
if (!DisconnectTip(state)) if (!DisconnectTip(state))
return false; 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); fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight);
while ( chainActive.Tip()->nHeight > KOMODO_REWIND ) while ( chainActive.Tip()->nHeight > KOMODO_REWIND )

View File

@@ -663,7 +663,7 @@ void static BitcoinMiner(CWallet *pwallet)
if ( i == 33 ) if ( i == 33 )
externalflag = 1; externalflag = 1;
else externalflag = 0; 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++) for (i=1; i<66; i++)
if ( memcmp(pubkeys[i],pubkeys[0],33) == 0 ) if ( memcmp(pubkeys[i],pubkeys[0],33) == 0 )
@@ -678,19 +678,21 @@ void static BitcoinMiner(CWallet *pwallet)
} }
for (j=gpucount=0; j<65; j++) for (j=gpucount=0; j<65; j++)
{ {
if ( mids[j] >= 0 ) if ( mids[j] >= 0 || notaryid == 34 )
fprintf(stderr,"%d ",mids[j]); fprintf(stderr,"%d ",mids[j]);
else fprintf(stderr,"GPU "); else fprintf(stderr,"GPU ");
if ( mids[j] == -1 ) if ( mids[j] == -1 )
gpucount++; 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++) for (j=0; j<65; j++)
if ( mids[j] == notaryid ) if ( mids[j] == notaryid )
break; break;
if ( j == 65 )
KOMODO_LASTMINED = 0;
} else fprintf(stderr,"no nonz pubkeys\n"); } 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); hashTarget = arith_uint256().SetCompact(KOMODO_MINDIFF_NBITS);
fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1); fprintf(stderr,"I am the chosen one for %s ht.%d\n",ASSETCHAINS_SYMBOL,pindexPrev->nHeight+1);