mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-27 23:34:20 +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; }
|
int64_t DifficultyAdjustmentInterval() const { return nPowTargetTimespan / nPowTargetSpacing; }
|
||||||
uint256 nMinimumChainWork;
|
uint256 nMinimumChainWork;
|
||||||
uint256 defaultAssumeValid;
|
uint256 defaultAssumeValid;
|
||||||
|
uint8_t GetCryptonoteMajorVersion() const { return 10; }
|
||||||
};
|
};
|
||||||
} // namespace Consensus
|
} // namespace Consensus
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
|
|||||||
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
|
pblock->hashPrevBlock = pindexPrev->GetBlockHash();
|
||||||
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
|
UpdateTime(pblock, chainparams.GetConsensus(), pindexPrev);
|
||||||
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, chainparams.GetConsensus());
|
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]);
|
pblocktemplate->vTxSigOpsCost[0] = WITNESS_SCALE_FACTOR * GetLegacySigOpCount(*pblock->vtx[0]);
|
||||||
|
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
|
@ -48,7 +48,7 @@ uint256 CBlockHeader::GetPoWHash() const
|
|||||||
uint256 thash;
|
uint256 thash;
|
||||||
if (hashPrevBlock.IsNull()) {
|
if (hashPrevBlock.IsNull()) {
|
||||||
// Genesis block
|
// 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;
|
return thash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ uint256 CBlockHeader::GetPoWHash() const
|
|||||||
return thash;
|
return thash;
|
||||||
}
|
}
|
||||||
cryptonote::blobdata blob = cryptonote::t_serializable_object_to_blob(cnHeader);
|
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;
|
return thash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,6 +124,8 @@ public:
|
|||||||
uint256 hashMerkleRoot;
|
uint256 hashMerkleRoot;
|
||||||
uint32_t nTime;
|
uint32_t nTime;
|
||||||
uint32_t nBits;
|
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;
|
uint32_t nNonce;
|
||||||
|
|
||||||
// CryptoNote header for emulation or merged mining
|
// CryptoNote header for emulation or merged mining
|
||||||
|
@ -477,7 +477,6 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
// Update nTime
|
// Update nTime
|
||||||
UpdateTime(pblock, consensusParams, pindexPrev);
|
UpdateTime(pblock, consensusParams, pindexPrev);
|
||||||
pblock->nNonce = 0;
|
|
||||||
|
|
||||||
std::set<std::string> setClientRules;
|
std::set<std::string> setClientRules;
|
||||||
UniValue aRules(UniValue::VARR);
|
UniValue aRules(UniValue::VARR);
|
||||||
@ -530,7 +529,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request)
|
|||||||
cryptonote::block cn_block;
|
cryptonote::block cn_block;
|
||||||
// block_header
|
// block_header
|
||||||
// const int cn_variant = b.major_version >= 7 ? b.major_version - 6 : 0;
|
// 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.minor_version = 0;
|
||||||
cn_block.timestamp = pblock->GetBlockTime();
|
cn_block.timestamp = pblock->GetBlockTime();
|
||||||
// The prev_id is used to store kevacoin block hash, as a proof of work.
|
// 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()));
|
(*pindex->phashBlock == block.GetHash()));
|
||||||
int64_t nTimeStart = GetTimeMicros();
|
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
|
// Check it again in case a previous version let a bad block in
|
||||||
// NOTE: We don't currently (re-)invoke ContextualCheckBlock() or
|
// NOTE: We don't currently (re-)invoke ContextualCheckBlock() or
|
||||||
// ContextualCheckBlockHeader() here. This means that if we add a new
|
// ContextualCheckBlockHeader() here. This means that if we add a new
|
||||||
|
Loading…
x
Reference in New Issue
Block a user