Skip to content

Commit

Permalink
Merge pull request #315 from jl777/beta
Browse files Browse the repository at this point in the history
beta update
  • Loading branch information
jl777 authored Mar 18, 2017
2 parents c86d576 + a5f3ea4 commit 8b14578
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 44 deletions.
14 changes: 5 additions & 9 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1244,14 +1244,10 @@ 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));
}
extern int32_t KOMODO_REWIND;
if ( KOMODO_REWIND == 0 )
{
if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3),
GetArg("-checkblocks", 288))) {
strLoadError = _("Corrupted block database detected");
break;
}
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());
Expand Down Expand Up @@ -1464,7 +1460,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
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))
if ( !ActivateBestChain(state))
strErrors << "Failed to connect best block";

std::vector<boost::filesystem::path> vImportFiles;
Expand Down
20 changes: 10 additions & 10 deletions src/komodo_gateway.h
Original file line number Diff line number Diff line change
Expand Up @@ -690,14 +690,12 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
}

//fprintf(stderr,"ht.%d n.%d nValue %.8f (%d %d %d)\n",height,n,dstr(block.vtx[0].vout[1].nValue),KOMODO_PAX,komodo_isrealtime(&ht),KOMODO_PASSPORT_INITDONE);
if ( komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 ||
return(0);
offset += komodo_scriptitemlen(&opretlen,&script[offset]);
if ( ASSETCHAINS_SYMBOL[0] == 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');
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');
opcode = 'X';
if ( height >= 235300 )
return(-1);
Expand All @@ -717,6 +715,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
return(0);
}
}
if ( komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 ||
return(0);
if ( script[offset] == opcode && opretlen < block.vtx[0].vout[n-1].scriptPubKey.size() )
{
if ( (num= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,&script[offset],opretlen,opcode == 'X')) > 0 )
Expand All @@ -735,9 +735,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
if ( opcode == 'I' && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) )
{
printf("checkdeposit.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed));
continue;
return(-1);
}
if ( ((opcode == 'I' && (pax->fiatoshis == 0 || pax->fiatoshis == block.vtx[0].vout[i].nValue)) || (opcode == 'X' && (pax->komodoshis == 0 || pax->komodoshis == block.vtx[0].vout[i].nValue))) )
if ( pax->fiatoshis == block.vtx[0].vout[i].nValue )
{
if ( pax->marked != 0 && height >= 80820 )
{
Expand Down Expand Up @@ -1127,7 +1127,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3

void komodo_passport_iteration()
{
static long lastpos[34]; static char userpass[33][1024]; int32_t maxseconds = 17;
static long lastpos[34]; static char userpass[33][1024]; int32_t maxseconds = 1;
FILE *fp; int32_t baseid,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0;
//printf("PASSPORT.(%s)\n",ASSETCHAINS_SYMBOL);
expired = 0;
Expand Down Expand Up @@ -1176,7 +1176,7 @@ void komodo_passport_iteration()
if ( 0 && lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 )
printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base);
fseek(fp,lastpos[baseid],SEEK_SET);
while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 && n < 10000 )
while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 && n < 1000 )
{
if ( n == 999 )
{
Expand Down Expand Up @@ -1207,7 +1207,7 @@ void komodo_passport_iteration()
isrealtime = 1;
RTmask |= (1LL << baseid);
memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1]));
} else if ( (time(NULL)-buf[2]) > 1800 )
} else if ( (time(NULL)-buf[2]) > 1800 && ASSETCHAINS_SYMBOL[0] != 0 )
fprintf(stderr,"[%s]: %s not RT %u %u %d\n",ASSETCHAINS_SYMBOL,base,buf[0],buf[1],(int32_t)(time(NULL)-buf[2]));
} //else fprintf(stderr,"%s size error RT\n",base);
fclose(fp);
Expand Down
2 changes: 1 addition & 1 deletion src/komodo_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,KOMODO_REWIND,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;
int32_t KOMODO_LASTMINED,prevKOMODO_LASTMINED;
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES;
uint8_t NOTARY_PUBKEY33[33];
Expand Down
6 changes: 4 additions & 2 deletions src/komodo_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1463,8 +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);
Expand Down
33 changes: 19 additions & 14 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1548,8 +1548,8 @@ bool IsInitialBlockDownload()
else if ( pindexBestHeader != 0 && pindexBestHeader->nHeight > ptr->nHeight )
ptr = pindexBestHeader;
if ( ASSETCHAINS_SYMBOL[0] == 0 )
state = (chainActive.Height() < ptr->nHeight - 24*6) ||
ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge());
state = ((chainActive.Height() < ptr->nHeight - 24*6) ||
ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge()));
else state = (chainActive.Height() < ptr->nHeight - 100);
//fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge()));
if (!state)
Expand Down Expand Up @@ -2758,7 +2758,6 @@ static void PruneBlockIndexCandidates() {
* pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork.
*/
static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMostWork, CBlock *pblock) {
extern int32_t KOMODO_REWIND;
AssertLockHeld(cs_main);
bool fInvalidFound = false;
const CBlockIndex *pindexOldTip = chainActive.Tip();
Expand All @@ -2769,21 +2768,28 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
if (!DisconnectTip(state))
return false;
}
if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight > KOMODO_REWIND )
/*fprintf(stderr,"chaintip %d vs rewind.%d\n",(int32_t)chainActive.Tip()->nHeight,KOMODO_REWIND);
if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND )
{
static int32_t didinit;
if ( didinit++ == 0 )
fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight);
while ( chainActive.Tip()->nHeight > KOMODO_REWIND )
{
while (chainActive.Tip()->nHeight > KOMODO_REWIND )
if ( !DisconnectTip(state) )
{
fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight);
if ( !DisconnectTip(state) )
return false;
//InvalidateBlock(state,chainActive.Tip());
return false;
}
pindexOldTip = chainActive.Tip();
pindexFork = chainActive.FindFork(pindexMostWork);
}
}
fprintf(stderr,"end rewind ht.%d\n",chainActive.Tip()->nHeight);
if ( chainActive.Tip()->nHeight == KOMODO_REWIND )
{
fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND);
sleep(3);
return(true);
}
pindexOldTip = chainActive.Tip();
pindexFork = chainActive.FindFork(pindexMostWork);
}*/
// Build list of new blocks to connect.
std::vector<CBlockIndex*> vpindexToConnect;
bool fContinue = true;
Expand Down Expand Up @@ -2859,7 +2865,6 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) {

if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL))
return false;

pindexNewTip = chainActive.Tip();
fInitialDownload = IsInitialBlockDownload();
}
Expand Down
2 changes: 1 addition & 1 deletion src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ void static BitcoinMiner(CWallet *pwallet)
LOCK(cs_vNodes);
fvNodesEmpty = vNodes.empty();
}
if (!fvNodesEmpty && !IsInitialBlockDownload())
if (!fvNodesEmpty )//&& !IsInitialBlockDownload())
break;
MilliSleep(5000);
//fprintf(stderr,"fvNodesEmpty %d IsInitialBlockDownload(%s) %d\n",(int32_t)fvNodesEmpty,ASSETCHAINS_SYMBOL,(int32_t)IsInitialBlockDownload());
Expand Down
7 changes: 4 additions & 3 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ extern std::string NOTARY_PUBKEY;

bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params)
{
extern int32_t KOMODO_REWIND;
//extern int32_t KOMODO_REWIND;
bool fNegative,fOverflow; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,duplicate,flag = 0, mids[66];
arith_uint256 bnTarget; CBlockIndex *pindex; uint8_t pubkeys[66][33];

Expand Down Expand Up @@ -155,15 +155,16 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
// Check proof of work matches claimed amount
if ( UintToArith256(hash) > bnTarget )
{
if ( (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 && KOMODO_REWIND == 0 )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0
if ( (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 )
//&& KOMODO_REWIND == 0 )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0
{
int32_t i;
for (i=31; i>=0; i--)
printf("%02x",((uint8_t *)&hash)[i]);
printf(" hash vs ");
for (i=31; i>=0; i--)
printf("%02x",((uint8_t *)&bnTarget)[i]);
printf(" ht.%d REWIND.%d special.%d notaryid.%d ht.%d mod.%d error\n",height,KOMODO_REWIND,special,notaryid,height,(height % 35));
printf(" ht.%d special.%d notaryid.%d ht.%d mod.%d error\n",height,special,notaryid,height,(height % 35));
for (i=0; i<33; i++)
printf("%02x",pubkey33[i]);
printf(" <- pubkey\n");
Expand Down
4 changes: 2 additions & 2 deletions src/rpcmining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,8 @@ Value getblocktemplate(const Array& params, bool fHelp)
if (vNodes.empty())
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Zcash is not connected!");

if (IsInitialBlockDownload())
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks...");
//if (IsInitialBlockDownload())
// throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks...");

static unsigned int nTransactionsUpdatedLast;

Expand Down
4 changes: 2 additions & 2 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,

void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex)
{
extern int32_t KOMODO_REWIND;
//extern int32_t KOMODO_REWIND;
{
LOCK(cs_wallet);
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
Expand Down Expand Up @@ -806,7 +806,7 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex)
extern char ASSETCHAINS_SYMBOL[16];
fprintf(stderr,"%s nWitnessCacheSize.%d\n",ASSETCHAINS_SYMBOL,(int32_t)nWitnessCacheSize);
}
if ( KOMODO_REWIND == 0 )
//if ( KOMODO_REWIND == 0 )
assert(nWitnessCacheSize > 0);
//if (fFileBacked) {
// CWalletDB walletdb(strWalletFile);
Expand Down

0 comments on commit 8b14578

Please sign in to comment.