mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-27 15:24:39 +00:00
WIP: added cn header to block header.
This commit is contained in:
parent
5e39efc98b
commit
80396a7a0f
@ -9,11 +9,8 @@
|
||||
#include <tinyformat.h>
|
||||
#include <utilstrencodings.h>
|
||||
#include <crypto/common.h>
|
||||
//#include <crypto/scrypt.h>
|
||||
extern "C"
|
||||
{
|
||||
#include <cryptonight/hash-ops.h>
|
||||
}
|
||||
|
||||
extern "C" void cn_slow_hash(const void *data, size_t length, char *hash, int variant, int prehashed);
|
||||
|
||||
uint256 CBlockHeader::GetHash() const
|
||||
{
|
||||
|
@ -10,6 +10,66 @@
|
||||
#include <serialize.h>
|
||||
#include <uint256.h>
|
||||
|
||||
#include <cryptonote_core/cryptonote_format_utils.h>
|
||||
|
||||
/**
|
||||
* This header is to store the proof-of-work of cryptonote mining.
|
||||
* Kevacoin uses Cryptonight PoW and uses its existing infrastructure
|
||||
* (mining pools and miners)
|
||||
*/
|
||||
class CryptoNoteHeader
|
||||
{
|
||||
public:
|
||||
uint8_t major_version;
|
||||
uint8_t minor_version; // now used as a voting mechanism, rather than how this particular block is built
|
||||
uint64_t timestamp;
|
||||
uint256 prev_id;
|
||||
uint32_t nonce;
|
||||
uint256 merkle_root;
|
||||
size_t nTxes; // Number of transactions.
|
||||
|
||||
CryptoNoteHeader()
|
||||
{
|
||||
SetNull();
|
||||
}
|
||||
|
||||
void SetNull()
|
||||
{
|
||||
major_version = 0;
|
||||
minor_version = 0;
|
||||
prev_id.SetNull();
|
||||
timestamp = 0;
|
||||
nonce = 0;
|
||||
merkle_root.SetNull();
|
||||
nTxes = 0;
|
||||
}
|
||||
|
||||
bool IsNull() const
|
||||
{
|
||||
return (timestamp == 0);
|
||||
}
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
VARINT_FIELD(major_version)
|
||||
VARINT_FIELD(minor_version)
|
||||
VARINT_FIELD(timestamp)
|
||||
crypto::hash prev_hash;
|
||||
memcpy(&prev_hash, prev_id.begin(), prev_id.size());
|
||||
FIELD(prev_hash)
|
||||
FIELD(nonce)
|
||||
END_SERIALIZE()
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action) {
|
||||
std::string blob = cryptonote::t_serializable_object_to_blob(*this);
|
||||
blob.append(reinterpret_cast<const char*>(merkle_root.begin()), merkle_root.size());
|
||||
blob.append(tools::get_varint_data(nTxes + 1));
|
||||
READWRITE(blob);
|
||||
}
|
||||
};
|
||||
|
||||
/** Nodes collect new transactions into a block, hash them into a hash tree,
|
||||
* and scan through nonce values to make the block's hash satisfy proof-of-work
|
||||
* requirements. When they solve the proof-of-work, they broadcast the block
|
||||
@ -28,6 +88,9 @@ public:
|
||||
uint32_t nBits;
|
||||
uint32_t nNonce;
|
||||
|
||||
// CryptoNote header for emulation or merged mining
|
||||
CryptoNoteHeader cnHeader;
|
||||
|
||||
CBlockHeader()
|
||||
{
|
||||
SetNull();
|
||||
@ -43,6 +106,10 @@ public:
|
||||
READWRITE(nTime);
|
||||
READWRITE(nBits);
|
||||
READWRITE(nNonce);
|
||||
// Genesis block does not have cnHeader.
|
||||
if (!hashPrevBlock.IsNull()) {
|
||||
READWRITE(cnHeader);
|
||||
}
|
||||
}
|
||||
|
||||
void SetNull()
|
||||
|
Loading…
x
Reference in New Issue
Block a user