MCPcopy Create free account
hub / github.com/LUX-Core/lux / GetHash

Method GetHash

src/primitives/block.cpp:19–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18
19uint256 CBlockHeader::GetHash(int nHeight,int Mining) const
20{
21//printf("%s height = %d (00) Mining ? %d\n",__func__,nHeight,Mining);
22 if (nHeight==0)
23 return Phi1612(BEGIN(nVersion), END(nNonce));
24
25//printf("%s height = %d (01)\n",__func__,nHeight);
26
27 bool randomxblock = (nHeight>=Params().SwitchRX2Block())? true:false;
28 bool phi2block = (nHeight>=Params().SwitchPhi2Block() && randomxblock!=true)? true:false;
29
30// printf("height = %d randomxblock %d phi2block %d switchrandomxblock %d switchphi2block %d \n",nHeight,randomxblock,phi2block,Params().SwitchRX2Block(),Params().SwitchPhi2Block());
31
32// phi2 algo
33 if (phi2block && (nVersion & (1 << 30)))
34 return phi2_hash(BEGIN(nVersion), END(hashUTXORoot));
35
36 if (phi2block && (nVersion > VERSIONBITS_LAST_OLD_BLOCK_VERSION))
37 return phi2_hash(BEGIN(nVersion), END(nNonce));
38
39// randomX algo
40 if (randomxblock) {
41 uint256 thisSeed;
42 if (Mining == 1 || Mining == 2)
43 thisSeed = GetRandomXSeed(nHeight);
44// barrysPreposterouslyNamedSeedHashFunction(nHeight, thisSeed);
45 uint256 thash;
46 if (Mining == 1) {
47// std::cout << " 1 height " << nHeight << " seed " << thisSeed.GetHex().c_str() << "size of the seed " << strlen(thisSeed.GetHex().c_str()) << std::endl;
48
49 rx_slow_hash((char*)this,(char*)&thash,144,thisSeed);
50 return thash;
51 } else if (Mining == 2) {
52// std::cout << "2 height " << nHeight << " seed " << thisSeed.GetHex().c_str() << "size of the seed " << strlen(thisSeed.GetHex().c_str()) << std::endl;
53 rx_slow_hash2((char*)this,(char*)&thash,144,thisSeed);
54 return thash;
55 } else {
56 if ((nVersion & (1 << 30)))
57 return phi2_hash(BEGIN(nVersion), END(hashUTXORoot));
58
59 if ((nVersion > VERSIONBITS_LAST_OLD_BLOCK_VERSION))
60 return phi2_hash(BEGIN(nVersion), END(nNonce));
61
62 }
63
64 }
65// for genesis hash and case the function is called without argument (nHeight==0)
66 return Phi1612(BEGIN(nVersion), END(nNonce));
67}
68
69
70uint256 CBlock::BuildMerkleTree(bool* fMutated) const

Callers 15

processTransactionMethod · 0.45
NotifyTransactionMethod · 0.45
NotifyTransactionLockMethod · 0.45
createVinMethod · 0.45
deleteResultsMethod · 0.45
GetPrevoutHashFunction · 0.45
GetSequenceHashFunction · 0.45
GetOutputsHashFunction · 0.45
SignatureHashFunction · 0.45
BuildTxsFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45

Calls 8

phi2_hashFunction · 0.85
GetRandomXSeedFunction · 0.85
rx_slow_hashFunction · 0.85
rx_slow_hash2Function · 0.85
SwitchRX2BlockMethod · 0.80
SwitchPhi2BlockMethod · 0.80
Phi1612Function · 0.50
ParamsClass · 0.50

Tested by 15

BuildTxsFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
SignatureHashOldFunction · 0.36
SetupDummyInputsFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
CreateCreditAndSpendFunction · 0.36
BuildSpendingTransactionFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36
TestPackageSelectionFunction · 0.36
BOOST_AUTO_TEST_CASEFunction · 0.36