mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-14 17:17:58 +00:00
Supported Cryptonight Variant 4.
This commit is contained in:
parent
8766247be1
commit
d48d05a182
@ -75,6 +75,7 @@ struct Params {
|
||||
int64_t DifficultyAdjustmentInterval() const { return nPowTargetTimespan / nPowTargetSpacing; }
|
||||
uint256 nMinimumChainWork;
|
||||
uint256 defaultAssumeValid;
|
||||
uint8_t GetCryptonoteMajorVersion() const { return 10; }
|
||||
};
|
||||
} // namespace Consensus
|
||||
|
||||
|
@ -175,7 +175,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
|
||||
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
|
||||
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
|
||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus());
|
||||
pblock->nNonce = 0;
|
||||
pblock->nNonce = nHeight; // nNonce now holds the height for Cryptonight variant 4
|
||||
pblocktemplate->vTxSigOpsCost[0] = WITNESS_SCALE_FACTOR * GetLegacySigOpCount(*pblock->vtx[0]);
|
||||
|
||||
CValidationState state;
|
||||
|
@ -48,7 +48,7 @@ uint256 CBlockHeader::GetPoWHash() const
|
||||
uint256 thash;
|
||||
if (hashPrevBlock.IsNull()) {
|
||||
// Genesis block
|
||||
cn_slow_hash(BEGIN(nVersion), 80, BEGIN(thash), 2, 0, 0);
|
||||
cn_slow_hash(BEGIN(nVersion), 80, BEGIN(thash), 4, 0, 0);
|
||||
return thash;
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ uint256 CBlockHeader::GetPoWHash() const
|
||||
return thash;
|
||||
}
|
||||
cryptonote::blobdata blob = cryptonote::t_serializable_object_to_blob(cnHeader);
|
||||
cn_slow_hash(blob.data(), blob.size(), BEGIN(thash), 2, 0, 0);
|
||||
cn_slow_hash(blob.data(), blob.size(), BEGIN(thash), cnHeader.major_version - 6, 0, nNonce);
|
||||
return thash;
|
||||
}
|
||||
|
||||
|
@ -124,6 +124,8 @@ public:
|
||||
uint256 hashMerkleRoot;
|
||||
uint32_t nTime;
|
||||
uint32_t nBits;
|
||||
// nNonce is no longer used as nonce, as the nonce is now in cnHeader.
|
||||
// Repurpose it for block height used in Cryptnight variant 4.
|
||||
uint32_t nNonce;
|
||||
|
||||
// CryptoNote header for emulation or merged mining
|
||||
|
@ -477,7 +477,6 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
|
||||
|
||||
// Update nTime
|
||||
UpdateTime(pblock, consensusParams, pindexPrev);
|
||||
pblock->nNonce = 0;
|
||||
|
||||
std::set<std::string> setClientRules;
|
||||
UniValue aRules(UniValue::VARR);
|
||||
@ -530,7 +529,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
|
||||
cryptonote::block cn_block;
|
||||
// block_header
|
||||
// const int cn_variant = b.major_version >= 7 ? b.major_version - 6 : 0;
|
||||
cn_block.major_version = 8; // cn variant 2
|
||||
cn_block.major_version = consensusParams.GetCryptonoteMajorVersion();
|
||||
cn_block.minor_version = 0;
|
||||
cn_block.timestamp = pblock->GetBlockTime();
|
||||
// The prev_id is used to store kevacoin block hash, as a proof of work.
|
||||
|
@ -1839,6 +1839,11 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
|
||||
(*pindex->phashBlock == block.GetHash()));
|
||||
int64_t nTimeStart = GetTimeMicros();
|
||||
|
||||
// Check the height of the block is the same as its height on the blockchain.
|
||||
// Note: nNonce now holds the value of height. It is no longer used as nonce.
|
||||
if (block.nNonce != pindex->nHeight)
|
||||
return error("%s: block height mismatch", __func__);
|
||||
|
||||
// Check it again in case a previous version let a bad block in
|
||||
// NOTE: We don't currently (re-)invoke ContextualCheckBlock() or
|
||||
// ContextualCheckBlockHeader() here. This means that if we add a new
|
||||
|
Loading…
Reference in New Issue
Block a user