forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgenesis.cpp
More file actions
39 lines (32 loc) · 1.15 KB
/
Copy pathgenesis.cpp
File metadata and controls
39 lines (32 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright (c) 2019-2021 Xenios SEZC
// https://www.veriblock.org
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <pow.h>
#include <util/strencodings.h>
#include <vbk/merkle.hpp>
#include "genesis.hpp"
namespace VeriBlock {
CBlock MineGenesisBlock(
uint32_t nTime,
const std::string& pszTimestamp,
const std::string& initialPubkeyHex,
uint32_t nBits,
uint32_t nVersion,
uint32_t nNonce, // starting nonce
uint64_t genesisReward)
{
CBlock genesis = CreateGenesisBlock(nTime, nNonce, nBits, nVersion, genesisReward, initialPubkeyHex, pszTimestamp);
printf("started genesis block mining...\n");
while (!CheckProofOfWork(genesis.GetHash(), genesis.nBits, Params().GetConsensus())) {
++genesis.nNonce;
if (genesis.nNonce > 4294967294LL) {
++genesis.nTime;
genesis.nNonce = 0;
printf("nonce reset... nTime=%d\n", genesis.nTime);
}
}
assert(CheckProofOfWork(genesis.GetHash(), genesis.nBits, Params().GetConsensus()));
return genesis;
}
} // namespace VeriBlock