mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
use block hash caching
This commit is contained in:
parent
257078d2a4
commit
f510cc309b
@ -1292,33 +1292,6 @@ bool CDarkSendPool::SignFinalTransaction(CTransaction& finalTransactionNew, CNod
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CDarkSendPool::GetBlockHash(uint256& hash, int nBlockHeight)
|
||||
{
|
||||
if(unitTest){
|
||||
hash.SetHex("00000000001432b4910722303bff579d0445fa23325bdc34538bdb226718ba79");
|
||||
return true;
|
||||
}
|
||||
|
||||
const CBlockIndex *BlockLastSolved = chainActive.Tip();
|
||||
const CBlockIndex *BlockReading = chainActive.Tip();
|
||||
|
||||
if (BlockLastSolved == NULL || BlockLastSolved->nHeight == 0) { return false; }
|
||||
|
||||
//printf(" nBlockHeight2 %d %d\n", nBlockHeight, chainActive.Tip()->nHeight+1);
|
||||
|
||||
for (unsigned int i = 1; BlockReading && BlockReading->nHeight > 0; i++) {
|
||||
if(BlockReading->nHeight == nBlockHeight) {
|
||||
hash = BlockReading->GetBlockHash();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (BlockReading->pprev == NULL) { assert(BlockReading); break; }
|
||||
BlockReading = BlockReading->pprev;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void CDarkSendPool::NewBlock()
|
||||
{
|
||||
if(fDebug) LogPrintf("CDarkSendPool::NewBlock \n");
|
||||
|
@ -407,8 +407,6 @@ public:
|
||||
// as a client, check and sign the final transaction
|
||||
bool SignFinalTransaction(CTransaction& finalTransactionNew, CNode* node);
|
||||
|
||||
// get block hash by height
|
||||
bool GetBlockHash(uint256& hash, int nBlockHeight);
|
||||
// get the last valid block hash for a given modulus
|
||||
bool GetLastValidBlockHash(uint256& hash, int mod=1, int nBlockHeight=0);
|
||||
// process a new block
|
||||
|
@ -680,7 +680,7 @@ bool CMasternodePayments::GetWinningMasternode(int nBlockHeight, CTxIn& vinOut)
|
||||
bool CMasternodePayments::AddWinningMasternode(CMasternodePaymentWinner& winnerIn)
|
||||
{
|
||||
uint256 blockHash = 0;
|
||||
if(!darkSendPool.GetBlockHash(blockHash, winnerIn.nBlockHeight-576)) {
|
||||
if(!GetBlockHash(blockHash, winnerIn.nBlockHeight-576)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user