Browse Source

Playin' dat Long Game with dat Longest Chain

dev
Duke Leto 4 years ago
parent
commit
aae0336733
  1. 4
      src/bitcoind.cpp
  2. 2
      src/hush_defs.h
  3. 2
      src/hush_globals.h
  4. 4
      src/komodo_bitcoind.h
  5. 6
      src/komodo_gateway.h
  6. 10
      src/main.cpp
  7. 4
      src/miner.cpp
  8. 2
      src/rpc/blockchain.cpp
  9. 2
      src/rpc/misc.cpp
  10. 4
      src/rpc/net.cpp

4
src/bitcoind.cpp

@ -62,7 +62,7 @@ extern int32_t ASSETCHAINS_BLOCKTIME;
extern uint64_t ASSETCHAINS_CBOPRET;
void hush_passport_iteration();
uint64_t komodo_interestsum();
int32_t komodo_longestchain();
int32_t hush_longestchain();
void komodo_cbopretupdate(int32_t forceflag);
CBlockIndex *komodo_chainactive(int32_t height);
@ -91,7 +91,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
}
} else {
//komodo_interestsum();
//komodo_longestchain();
//hush_longestchain();
if ( ASSETCHAINS_CBOPRET != 0 )
komodo_cbopretupdate(0);
for (i=0; i<=ASSETCHAINS_BLOCKTIME/5; i++)

2
src/hush_defs.h

@ -546,7 +546,7 @@ int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width);
int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen);
uint32_t komodo_blocktime(uint256 hash);
int32_t komodo_longestchain();
int32_t hush_longestchain();
int32_t hush_dpowconfs(int32_t height,int32_t numconfs);
int8_t komodo_segid(int32_t nocache,int32_t height);
int32_t komodo_heightpricebits(uint64_t *seedp,uint32_t *heightbits,int32_t nHeight);

2
src/hush_globals.h

@ -29,7 +29,7 @@ void komodo_init(int32_t height);
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
int32_t komodo_isrealtime(int32_t *kmdheightp);
uint64_t komodo_paxtotal();
int32_t komodo_longestchain();
int32_t hush_longestchain();
uint64_t komodo_maxallowed(int32_t baseid);
int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max);
int32_t komodo_checkvout(int32_t vout,int32_t k,int32_t indallvouts);

4
src/komodo_bitcoind.h

@ -1186,7 +1186,7 @@ int32_t komodo_nextheight()
CBlockIndex *pindex; int32_t ht;
if ( (pindex= chainActive.LastTip()) != 0 && (ht= pindex->GetHeight()) > 0 )
return(ht+1);
else return(komodo_longestchain() + 1);
else return(hush_longestchain() + 1);
}
int32_t komodo_isrealtime(int32_t *kmdheightp)
@ -1195,7 +1195,7 @@ int32_t komodo_isrealtime(int32_t *kmdheightp)
if ( (sp= komodo_stateptrget((char *)"KMD")) != 0 )
*kmdheightp = sp->CURRENT_HEIGHT;
else *kmdheightp = 0;
if ( (pindex= chainActive.LastTip()) != 0 && pindex->GetHeight() >= (int32_t)komodo_longestchain() )
if ( (pindex= chainActive.LastTip()) != 0 && pindex->GetHeight() >= (int32_t)hush_longestchain() )
return(1);
else return(0);
}

6
src/komodo_gateway.h

@ -1438,7 +1438,7 @@ void hush_passport_iteration()
{
if ( SMART_CHAIN_SYMBOL[0] == 0 )
komodo_interestsum();
//komodo_longestchain();
//hush_longestchain();
lastinterest = komodo_chainactive_timestamp();
}
refsp = komodo_stateptr(symbol,dest);
@ -1542,7 +1542,7 @@ void hush_passport_iteration()
if ( (fp= fopen(fname,"wb")) != 0 )
{
buf[0] = (uint32_t)chainActive.LastTip()->GetHeight();
buf[1] = (uint32_t)komodo_longestchain();
buf[1] = (uint32_t)hush_longestchain();
if ( buf[0] != 0 && buf[0] == buf[1] )
{
buf[2] = (uint32_t)time(NULL);
@ -1559,7 +1559,7 @@ void hush_passport_iteration()
if ( sp != 0 && isrealtime == 0 )
refsp->RTbufs[0][2] = 0;
}
//komodo_paxtotal(); // calls komodo_isrealtime(), which calls komodo_longestchain()
//komodo_paxtotal(); // calls komodo_isrealtime(), which calls hush_longestchain()
refsp->RTmask |= RTmask;
if ( expired == 0 && HUSH_PASSPORT_INITDONE == 0 )
{

10
src/main.cpp

@ -3941,7 +3941,7 @@ void static UpdateTip(CBlockIndex *pindexNew) {
if ( SMART_CHAIN_SYMBOL[0] == 0 ) {
progress = Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), chainActive.LastTip());
} else {
int32_t longestchain = komodo_longestchain();
int32_t longestchain = hush_longestchain();
progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0;
}
@ -5611,7 +5611,7 @@ bool AcceptBlock(int32_t *futureblockp,CBlock& block, CValidationState& state, C
{
CValidationState tmpstate; CBlockIndex *tmpindex; int32_t ht,longest;
ht = (int32_t)pindex->GetHeight();
longest = komodo_longestchain();
longest = hush_longestchain();
if ( (longest == 0 || ht < longest-6) && (tmpindex=komodo_chainactive(ht)) != 0 )
{
fprintf(stderr,"reconsider height.%d, longest.%d\n",(int32_t)ht,longest);
@ -5824,7 +5824,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo
//fprintf(stderr,"request headers from failed process block peer\n");
pfrom->PushMessage("getheaders", chainActive.GetLocator(chainActive.LastTip()), uint256());
}*/
komodo_longestchain();
hush_longestchain();
return error("%s: AcceptBlock FAILED", __func__);
}
//else fprintf(stderr,"added block %s %p\n",pindex->GetBlockHash().ToString().c_str(),pindex->pprev);
@ -6309,8 +6309,8 @@ bool static LoadBlockIndexDB()
if ( SMART_CHAIN_SYMBOL[0] == 0 ) {
progress = Checkpoints::GuessVerificationProgress(chainparams.Checkpoints(), chainActive.LastTip());
} else {
int32_t longestchain = komodo_longestchain();
// TODO: komodo_longestchain does not have the data it needs at the time LoadBlockIndexDB
int32_t longestchain = hush_longestchain();
// TODO: hush_longestchain does not have the data it needs at the time LoadBlockIndexDB
// runs, which makes it return 0, so we guess 50% for now
progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 0.5;
}

4
src/miner.cpp

@ -144,7 +144,7 @@ int32_t My_notaryid = -1;
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize);
int32_t komodo_baseid(char *origbase);
int32_t komodo_longestchain();
int32_t hush_longestchain();
int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag);
int64_t komodo_block_unlocktime(uint32_t nHeight);
uint64_t komodo_commission(const CBlock *block,int32_t height);
@ -1313,7 +1313,7 @@ void static BitcoinMiner()
//fprintf(stderr,"gotinvalid.%d\n",gotinvalid);
if ( gotinvalid != 0 )
break;
komodo_longestchain();
hush_longestchain();
// Hash state
KOMODO_CHOSEN_ONE = 0;

2
src/rpc/blockchain.cpp

@ -1651,7 +1651,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp, const CPubKey& my
if ( SMART_CHAIN_SYMBOL[0] == 0 ) {
progress = Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.LastTip());
} else {
int32_t longestchain = HUSH_LONGESTCHAIN;//komodo_longestchain();
int32_t longestchain = HUSH_LONGESTCHAIN;//hush_longestchain();
progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0;
}
notarized_height = komodo_notarized_height(&prevMoMheight,&notarized_hash,&notarized_desttxid);

2
src/rpc/misc.cpp

@ -55,7 +55,7 @@ using namespace std;
**/
uint64_t komodo_interestsum();
int32_t komodo_longestchain();
int32_t hush_longestchain();
int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp);
bool komodo_txnotarizedconfirmed(uint256 txid);
uint32_t komodo_chainactive_timestamp();

4
src/rpc/net.cpp

@ -178,7 +178,7 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp, const CPubKey& mypk)
}
int32_t HUSH_LONGESTCHAIN;
int32_t komodo_longestchain()
int32_t hush_longestchain()
{
static int32_t depth;
int32_t ht,n=0,num=0,maxheight=0,height = 0;
@ -194,7 +194,7 @@ int32_t komodo_longestchain()
}
BOOST_FOREACH(const CNodeStats& stats, vstats)
{
//fprintf(stderr,"komodo_longestchain iter.%d\n",n);
//fprintf(stderr,"hush_longestchain iter.%d\n",n);
CNodeStateStats statestats;
bool fStateStats = GetNodeStateStats(stats.nodeid,statestats);
if ( statestats.nSyncHeight < 0 )

Loading…
Cancel
Save