hacktober fest #214
7 changed files with 139 additions and 38 deletions
|
@ -55,7 +55,7 @@ static void convertSeed6(std::vector<CAddress> &vSeedsOut, const SeedSpec6 *data
|
|||
|
||||
static Checkpoints::MapCheckpoints mapCheckpoints =
|
||||
boost::assign::map_list_of
|
||||
( 0, uint256S("0x00ef6ded2b610fc5e4f06d187d12136bd5fba7b932fa0b66bf353c7c1648ec9c"));
|
||||
( 0, uint256S("0x0000343f59c49eb433ba3a37ee4b3493ff014ee9b266f610bb3cd1b36927787a"));
|
||||
/*static Checkpoints::MapCheckpoints mapCheckpoints =
|
||||
boost::assign::map_list_of
|
||||
( 11111, uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d"))
|
||||
|
@ -110,7 +110,7 @@ public:
|
|||
consensus.nMajorityEnforceBlockUpgrade = 750;
|
||||
consensus.nMajorityRejectBlockOutdated = 950;
|
||||
consensus.nMajorityWindow = 1000;
|
||||
consensus.powLimit = ~arith_uint256(0) >> 1;
|
||||
consensus.powLimit = ~arith_uint256(0) >> 16;
|
||||
consensus.nPowTargetTimespan = 30 * 60 * 12;//14 * 24 * 60 * 60; // two weeks
|
||||
consensus.nPowTargetSpacing = 30;
|
||||
consensus.fPowAllowMinDifficultyBlocks = false;
|
||||
|
@ -145,37 +145,39 @@ public:
|
|||
txNew.vout[0].nValue = 50 * COIN;
|
||||
//txNew.vout[0].scriptPubKey = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
|
||||
//txNew.vout[0].scriptPubKey = CScript() << ParseHex("0425caecb9fbf6cf50979644e85c11e3ec9007fd477fab9683648c6539e59b59c3a4d9b9c0b552c37eee6476f3e0d8425ac0346fe69ad61628b8c340d42fbfa3fd") << OP_CHECKSIG;
|
||||
txNew.vout[0].scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ParseHex("e5ff2d9e3a254622ae493573169c0fa94c82fe4f") << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||
//txNew.vout[0].scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ParseHex("e5ff2d9e3a254622ae493573169c0fa94c82fe4f") << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||
txNew.vout[0].scriptPubKey = CScript() << OP_DUP << OP_HASH160 << ParseHex("345991dbf57bfb014b87006acdfafbfc5fe8292f") << OP_EQUALVERIFY << OP_CHECKSIG;
|
||||
genesis.vtx.push_back(txNew);
|
||||
genesis.hashPrevBlock.SetNull();
|
||||
genesis.hashMerkleRoot = genesis.BuildMerkleTree();
|
||||
genesis.hashNCCTrie = uint256S("0x0000000000000000000000000000000000000000000000000000000000000001");
|
||||
genesis.nVersion = 1;
|
||||
genesis.nTime = 1417453734;
|
||||
genesis.nBits = 0x207fffff;//0x1d00ffff;
|
||||
genesis.nNonce = 601;
|
||||
genesis.nBits = 0x1f00ffff;//0x207fffff;//0x1d00ffff;
|
||||
genesis.nNonce = 7885;
|
||||
|
||||
/*bool found = false;
|
||||
while (!found)
|
||||
{
|
||||
genesis.nNonce += 1;
|
||||
hashGenesisBlock = genesis.GetHash();
|
||||
const char * hex = hashGenesisBlock.GetHex().c_str();
|
||||
if (hex[0] == '0' && hex[1] == '0')
|
||||
consensus.hashGenesisBlock = genesis.GetHash();
|
||||
if (CheckProofOfWork2(consensus.hashGenesisBlock, consensus.powLimit.GetCompact(), consensus))
|
||||
{
|
||||
printf("nonce: %d\n", genesis.nNonce);
|
||||
printf("hex: %s\n", hex);
|
||||
std::cout << "nonce: " << genesis.nNonce << std::endl;
|
||||
std::cout << "hex: " << consensus.hashGenesisBlock.GetHex() << std::endl;
|
||||
found = true;
|
||||
}
|
||||
}*/
|
||||
|
||||
consensus.hashGenesisBlock = genesis.GetHash();
|
||||
//printf("%s\n", hashGenesisBlock.GetHex().c_str());
|
||||
//printf("hex: %s\n", consensus.hashGenesisBlock.GetHex().c_str());
|
||||
//assert(consensus.hashGenesisBlock == uint256S("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
|
||||
assert(consensus.hashGenesisBlock == uint256S("0x00ef6ded2b610fc5e4f06d187d12136bd5fba7b932fa0b66bf353c7c1648ec9c"));
|
||||
//assert(consensus.hashGenesisBlock == uint256S("0x00ef6ded2b610fc5e4f06d187d12136bd5fba7b932fa0b66bf353c7c1648ec9c"));
|
||||
assert(consensus.hashGenesisBlock == uint256S("0x0000343f59c49eb433ba3a37ee4b3493ff014ee9b266f610bb3cd1b36927787a"));
|
||||
//printf("%s\n", genesis.hashMerkleRoot.GetHex().c_str());
|
||||
//assert(genesis.hashMerkleRoot == uint256("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
|
||||
assert(genesis.hashMerkleRoot == uint256S("0xa7d51d407092059a2beeffab22e65d6176cfb3c33b93515109480aa7c81c9141"));
|
||||
//assert(genesis.hashMerkleRoot == uint256S("0xa7d51d407092059a2beeffab22e65d6176cfb3c33b93515109480aa7c81c9141"));
|
||||
assert(genesis.hashMerkleRoot == uint256S("0x93621531f4de4b27d4ffdf785ef12855f2b18687e2141466ff50e2848d83f551"));
|
||||
|
||||
//vSeeds.push_back(CDNSSeedData("bitcoin.sipa.be", "seed.bitcoin.sipa.be"));
|
||||
//vSeeds.push_back(CDNSSeedData("bluematt.me", "dnsseed.bluematt.me"));
|
||||
|
|
11
src/main.cpp
11
src/main.cpp
|
@ -1094,7 +1094,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
|
|||
if (coins)
|
||||
nHeight = coins->nHeight;
|
||||
}
|
||||
if (nHeight > 0)
|
||||
if (nHeight >= 0)
|
||||
pindexSlow = chainActive[nHeight];
|
||||
}
|
||||
}
|
||||
|
@ -1358,6 +1358,7 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
|
|||
coins->Spend(nPos);
|
||||
if (coins->vout.size() == 0) {
|
||||
CTxInUndo& undo = txundo.vprevout.back();
|
||||
undo.fLastUnspent = true;
|
||||
undo.nHeight = coins->nHeight;
|
||||
undo.fCoinBase = coins->fCoinBase;
|
||||
undo.nVersion = coins->nVersion;
|
||||
|
@ -1555,8 +1556,8 @@ static bool ApplyTxInUndo(const CTxInUndo& undo, CCoinsViewCache& view, CNCCTrie
|
|||
bool fClean = true;
|
||||
|
||||
CCoinsModifier coins = view.ModifyCoins(out.hash);
|
||||
if (undo.nHeight != 0) {
|
||||
// undo data contains height: this is the last output of the prevout tx being spent
|
||||
if (undo.fLastUnspent) {
|
||||
// this is the last output of the prevout tx being spent
|
||||
if (!coins->IsPruned())
|
||||
fClean = fClean && error("%s: undo data overwriting existing transaction", __func__);
|
||||
coins->Clear();
|
||||
|
@ -1741,7 +1742,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
view.SetBestBlock(pindex->GetBlockHash());
|
||||
trieCache.setBestBlock(pindex->GetBlockHash());
|
||||
}
|
||||
return true;
|
||||
//return true;
|
||||
}
|
||||
|
||||
bool fScriptChecks = pindex->nHeight >= Checkpoints::GetTotalBlocksEstimate();
|
||||
|
@ -1945,7 +1946,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
|||
return true;
|
||||
|
||||
// Write undo information to disk
|
||||
if (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS))
|
||||
if (!(block.GetHash() == Params().HashGenesisBlock()) && (pindex->GetUndoPos().IsNull() || !pindex->IsValid(BLOCK_VALID_SCRIPTS)))
|
||||
{
|
||||
if (pindex->GetUndoPos().IsNull()) {
|
||||
CDiskBlockPos pos;
|
||||
|
|
|
@ -137,6 +137,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
|||
CBlockIndex* pindexPrev = chainActive.Tip();
|
||||
const int nHeight = pindexPrev->nHeight + 1;
|
||||
CCoinsViewCache view(pcoinsTip);
|
||||
if (!pnccTrie)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
CNCCTrieCache trieCache(pnccTrie);
|
||||
|
||||
// Priority order to process transactions
|
||||
|
|
|
@ -147,7 +147,7 @@ class CNCCTrieCache;
|
|||
class CNCCTrie
|
||||
{
|
||||
public:
|
||||
CNCCTrie(bool fMemory = false, bool fWipe = false) : db(GetDataDir() / "ncctrie", 100, fMemory, fWipe), nCurrentHeight(1), root(uint256S("0000000000000000000000000000000000000000000000000000000000000001")) {}
|
||||
CNCCTrie(bool fMemory = false, bool fWipe = false) : db(GetDataDir() / "ncctrie", 100, fMemory, fWipe), nCurrentHeight(0), root(uint256S("0000000000000000000000000000000000000000000000000000000000000001")) {}
|
||||
uint256 getMerkleHash();
|
||||
CLevelDBWrapper db;
|
||||
bool empty() const;
|
||||
|
@ -188,7 +188,7 @@ private:
|
|||
class CNCCTrieCache
|
||||
{
|
||||
public:
|
||||
CNCCTrieCache(CNCCTrie* base): base(base), nCurrentHeight(base->nCurrentHeight) {}
|
||||
CNCCTrieCache(CNCCTrie* base): base(base) {assert(base); nCurrentHeight = base->nCurrentHeight;}
|
||||
uint256 getMerkleHash() const;
|
||||
bool empty() const;
|
||||
bool flush();
|
||||
|
|
|
@ -49,7 +49,7 @@ struct {
|
|||
{2, 0xbbbeb305}, {2, 0xfe1c810a},
|
||||
};*/
|
||||
|
||||
static
|
||||
/*static
|
||||
struct {
|
||||
unsigned char extranonce;
|
||||
unsigned int nonce;
|
||||
|
@ -82,6 +82,20 @@ struct {
|
|||
{1, 0x00000000}, {1, 0x00000000}, {1, 0x00000000}, {5, 0x00000000}, //100
|
||||
{2, 0x00000000}, {1, 0x00000002}, {1, 0x00000000}, {1, 0x00000001}, //104
|
||||
{2, 0x00000003}, {2, 0x00000000}, //108
|
||||
};*/
|
||||
|
||||
const unsigned int nonces[] = {
|
||||
114541, 40175, 23379, 121337, 4042, 35872, 42421, 145983, 4319, 8578,
|
||||
41220, 74215, 146557, 50967, 88259, 58152, 268596, 5792, 143361, 44697,
|
||||
43002, 21193, 70268, 162059, 38523, 30695, 138206, 87472, 134523, 57662,
|
||||
9345, 155238, 43247, 16926, 275759, 12455, 28819, 106643, 45302, 60635,
|
||||
154668, 2603, 450823, 53229, 165143, 105432, 165849, 25684, 75902, 56928,
|
||||
14741, 30997, 8054, 37001, 18039, 1756, 121352, 93199, 34162, 30404,
|
||||
40672, 8901, 67062, 36928, 29084, 73141, 61906, 12881, 114189, 47550,
|
||||
9109, 118675, 12945, 190955, 5882, 144237, 38280, 56629, 69485, 32170,
|
||||
51951, 117891, 6592, 22601, 5958, 70998, 193724, 11394, 40056, 14009,
|
||||
8935, 15990, 22127, 13847, 6130, 60578, 13413, 33884, 91806, 44141,
|
||||
24658, 5826, 148899, 32744, 42810, 9978, 54633, 153655, 28932, 73692
|
||||
};
|
||||
|
||||
// NOTE: These tests rely on CreateNewBlock doing its own self-validation!
|
||||
|
@ -102,32 +116,33 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
|||
// We can't make transactions until we have inputs
|
||||
// Therefore, load 100 blocks :)
|
||||
std::vector<CTransaction*>txFirst;
|
||||
for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i)
|
||||
for (unsigned int i = 0; i < 110; ++i)
|
||||
{
|
||||
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
|
||||
pblock->nVersion = 1;
|
||||
pblock->nTime = chainActive.Tip()->GetMedianTimePast()+1;
|
||||
CMutableTransaction txCoinbase(pblock->vtx[0]);
|
||||
txCoinbase.vin[0].scriptSig = CScript();
|
||||
txCoinbase.vin[0].scriptSig.push_back(blockinfo[i].extranonce);
|
||||
txCoinbase.vin[0].scriptSig.push_back(0);
|
||||
txCoinbase.vin[0].scriptSig.push_back(chainActive.Height());
|
||||
txCoinbase.vout[0].scriptPubKey = CScript();
|
||||
pblock->vtx[0] = CTransaction(txCoinbase);
|
||||
if (txFirst.size() < 2)
|
||||
txFirst.push_back(new CTransaction(pblock->vtx[0]));
|
||||
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
|
||||
pblock->nNonce = blockinfo[i].nonce;
|
||||
pblock->nNonce = nonces[i];
|
||||
/*bool fFound = false;
|
||||
for (int j = 0; !fFound; j++)
|
||||
{
|
||||
pblock->nNonce = j;
|
||||
if (CheckProofOfWork(pblock->GetHash(), pblock->nBits))
|
||||
if (CheckProofOfWork(pblock->GetHash(), pblock->nBits, Params().GetConsensus()))
|
||||
{
|
||||
fFound = true;
|
||||
if (i % 4 == 0)
|
||||
std::cout << pblock->nNonce << ",";
|
||||
if ((i + 1) % 10 == 0)
|
||||
std::cout << std::endl;
|
||||
std::cout << "Block number: " << i << std::endl;
|
||||
std::cout << "Nonce: " << std::hex << pblock->nNonce << std::dec << std::endl;
|
||||
else
|
||||
std::cout << " ";
|
||||
}
|
||||
}*/
|
||||
CValidationState state;
|
||||
|
|
|
@ -14,6 +14,75 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
const unsigned int nonces[] = {
|
||||
62302, 78404, 42509, 88397, 232147, 34120, 48944, 8449, 3855, 99418,
|
||||
35007, 36992, 18865, 48021, 117592, 61911, 26614, 26267, 171911, 49917,
|
||||
68274, 19360, 48650, 22711, 102612, 73362, 7375, 39379, 413, 123283,
|
||||
51264, 50359, 11329, 126833, 56973, 48128, 183377, 122530, 68435, 16223,
|
||||
201782, 6345, 169401, 49980, 340128, 21022, 54403, 2304, 57721, 257910,
|
||||
31720, 13689, 73758, 43961, 14926, 90259, 23943, 75907, 70683, 91654,
|
||||
2788, 110836, 21685, 78041, 3310, 39497, 1774, 51369, 59835, 41272,
|
||||
41575, 63281, 25029, 87528, 285, 34225, 48228, 5152, 22230, 83385,
|
||||
11314, 192174, 75562, 116667, 385684, 56288, 23660, 18636, 228282, 114723,
|
||||
623, 251464, 15557, 88445, 141000, 111823, 3972, 25959, 26559, 137659,
|
||||
47864, 70562, 102076, 827, 28810, 29768, 71901, 45824, 81128, 144277,
|
||||
23405, 14275, 23837, 2713, 24162, 49329, 115878, 50877, 124383, 144840,
|
||||
266179, 121554, 47532, 6247, 28255, 254151, 48955, 84748, 241948, 35275,
|
||||
16909, 133791, 93138, 59518, 70972, 120051, 109811, 20584, 17823, 101763,
|
||||
25577, 24277, 3482, 42387, 103600, 79949, 93276, 3258, 13991, 10782,
|
||||
344259, 77179, 100907, 79587, 9552, 48822, 16915, 73331, 37263, 112357,
|
||||
31685, 46691, 155015, 119072, 9543, 2292, 89140, 13762, 29899, 36874,
|
||||
122924, 42, 22902, 36627, 4244, 37166, 34686, 120765, 10210, 134614,
|
||||
23799, 149425, 120024, 27766, 22997, 31651, 4055, 9770, 67895, 81757,
|
||||
13057, 50235, 166795, 22267, 155530, 28458, 135516, 47850, 14820, 54174,
|
||||
66691, 196100, 31644, 9822, 72770, 46088, 11563, 124579, 131847, 33348,
|
||||
49053, 64349, 258375, 24202, 96640, 42232, 116531, 133425, 50283, 77773,
|
||||
21118, 137282, 165647, 83029, 144604, 81135, 67711, 132395, 29024, 140422,
|
||||
34761, 56323, 43292, 63797, 5586, 48860, 56797, 101110, 16820, 166363,
|
||||
109360, 78408, 223452, 3201, 60430, 21485, 33348, 112307, 2390, 10911,
|
||||
25658, 22369, 62658, 82807, 37511, 45794, 19810, 17668, 72189, 369983,
|
||||
5117, 208398, 196524, 171, 7371, 24445, 110133, 72669, 89731, 99758,
|
||||
29522, 55820, 60793, 31310, 171461, 80660, 123819, 58962, 54153, 53058,
|
||||
1729, 62947, 51374, 133045, 4983, 33163, 8340, 13066, 29664, 4474,
|
||||
235529, 253826, 80953, 64694, 277894, 19611, 13659, 30347, 31926, 4686,
|
||||
80304, 6650, 31670, 174453, 136085, 223321, 15262, 3299, 34516, 137382,
|
||||
106996, 68709, 17486, 110837, 157075, 11078, 157597, 11171, 127598, 64125,
|
||||
57626, 58654, 44730, 107781, 22635, 94765, 10103, 20723, 7509, 1081,
|
||||
24352, 4846, 29187, 453703, 5114, 1244, 626, 133986, 47067, 4149,
|
||||
110343, 21613, 33002, 120824, 109164, 51170, 83888, 4209, 2421, 57893,
|
||||
164672, 16594, 51217, 118785, 31325, 1017, 64481, 13050, 37412, 169320,
|
||||
13569, 26559, 51805, 71218, 236435, 114049, 492, 16652, 40248, 13693,
|
||||
21022, 20441, 2176, 188005, 60471, 3688, 3054, 170834, 23534, 19256,
|
||||
50302, 30519, 22514, 4447, 85147, 25983, 85002, 20411, 40249, 22878,
|
||||
14010, 44647, 34606, 186404, 110909, 36338, 62987, 29983, 7192, 35465,
|
||||
2995, 33457, 93500, 24146, 38031, 11953, 66874, 7590, 139803, 9525,
|
||||
53444, 254006, 26853, 16617, 35308, 71741, 59383, 37348, 156748, 93838,
|
||||
96215, 47298, 35119, 58025, 51044, 145982, 8151, 177835, 6315, 15025,
|
||||
2504, 215135, 103144, 2492, 192, 38240, 57417, 11725, 48369, 182146,
|
||||
10941, 63185, 160233, 34699, 35012, 158130, 37669, 26041, 36852, 37891,
|
||||
9879, 9892, 34605, 25583, 3323, 160175, 6951, 44767, 5039, 62761,
|
||||
27795, 179460, 7358, 216, 10407, 257742, 69315, 2617, 134737, 66435,
|
||||
56215, 17714, 38908, 47160, 21354, 31881, 42867, 58843, 26370, 11260,
|
||||
11813, 212327, 33685, 113596, 105159, 73144, 24356, 97897, 20602, 10452,
|
||||
12250, 62390, 38375, 60273, 23336, 33806, 40617, 22276, 60715, 194148,
|
||||
50822, 110070, 2102, 6397, 70139, 10539, 8155, 183926, 19102, 34694,
|
||||
158006, 73770, 18564, 37019, 12673, 12681, 19243, 35069, 235750, 12110,
|
||||
17397, 2317, 213831, 12315, 78126, 116545, 107835, 116366, 57241, 22608,
|
||||
79014, 32275, 12060, 55835, 17401, 102239, 14668, 20121, 4119, 30656,
|
||||
69942, 66483, 25954, 12711, 121536, 12394, 84011, 12767, 56377, 164783,
|
||||
37048, 88712, 58853, 129293, 472, 37208, 368, 45723, 127506, 44908,
|
||||
1203, 129491, 153675, 2208, 1315, 120624, 32408, 90338, 99397, 72400,
|
||||
4403, 32782, 62787, 11962, 15175, 83275, 24585, 6447, 81927, 4001,
|
||||
108118, 48080, 141528, 36406, 9629, 46372, 16180, 48559, 128234, 212518,
|
||||
47805, 232605, 245798, 15869, 68322, 4530, 19700, 10275, 120746, 46854,
|
||||
54898, 29476, 74410, 247807, 39933, 46868, 56451, 36564, 103828, 41302,
|
||||
28903, 11601, 119842, 23196, 219677, 61984, 706, 66649, 56481, 14360,
|
||||
128017, 19310, 12892, 3295, 37737, 100578, 26914, 27946, 2172, 212021,
|
||||
3100, 79199, 7024, 129311, 43027, 9696, 86251, 9574, 113123, 32433,
|
||||
18065, 121598, 5003, 11516, 138320, 46619, 96118, 85037, 14106, 7904,
|
||||
102894, 41478, 509, 169951, 5571, 28284, 8138, 53248, 47878, 113791,
|
||||
192277, 73645, 28672, 93670, 30741, 129667};
|
||||
|
||||
BOOST_FIXTURE_TEST_SUITE(ncctrie_tests, TestingSetup)
|
||||
|
||||
CMutableTransaction BuildTransaction(const uint256& prevhash)
|
||||
|
@ -71,12 +140,20 @@ bool CreateBlock(CBlockTemplate* pblocktemplate, bool f = false)
|
|||
txCoinbase.vout[0].nValue = GetBlockValue(chainActive.Height(), 0);
|
||||
pblock->vtx[0] = CTransaction(txCoinbase);
|
||||
pblock->hashMerkleRoot = pblock->BuildMerkleTree();
|
||||
for (int i = 0; ; ++i)
|
||||
pblock->nNonce = nonces[unique_block_counter - 1];
|
||||
/*for (int i = 0; ; ++i)
|
||||
{
|
||||
pblock->nNonce = i;
|
||||
if (CheckProofOfWork(pblock->GetHash(), pblock->nBits, Params().GetConsensus()))
|
||||
{
|
||||
std::cout << pblock->nNonce << ",";
|
||||
if (unique_block_counter % 10 == 0)
|
||||
std::cout << std::endl;
|
||||
else
|
||||
std::cout << " ";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
CValidationState state;
|
||||
bool success = (ProcessNewBlock(state, NULL, pblock) && state.IsValid() && pblock->GetHash() == chainActive.Tip()->GetBlockHash());
|
||||
pblock->hashPrevBlock = pblock->GetHash();
|
||||
|
|
18
src/undo.h
18
src/undo.h
|
@ -21,25 +21,26 @@ class CTxInUndo
|
|||
{
|
||||
public:
|
||||
CTxOut txout; // the txout data before being spent
|
||||
bool fLastUnspent; // whether the outpoint was the last unspent
|
||||
bool fCoinBase; // if the outpoint was the last unspent: whether it belonged to a coinbase
|
||||
unsigned int nHeight; // if the outpoint was the last unspent: its height
|
||||
int nVersion; // if the outpoint was the last unspent: its version
|
||||
unsigned int nNCCValidHeight; // If the outpoint was an NCC claim, the height at which the claim should be inserted into the trie
|
||||
|
||||
CTxInUndo() : txout(), fCoinBase(false), nHeight(0), nVersion(0), nNCCValidHeight(0) {}
|
||||
CTxInUndo() : txout(), fLastUnspent(false), fCoinBase(false), nHeight(0), nVersion(0), nNCCValidHeight(0) {}
|
||||
CTxInUndo(const CTxOut &txoutIn, bool fCoinBaseIn = false, unsigned int nHeightIn = 0, int nVersionIn = 0, unsigned int nNCCValidHeight = 0) : txout(txoutIn), fCoinBase(fCoinBaseIn), nHeight(nHeightIn), nVersion(nVersionIn), nNCCValidHeight(nNCCValidHeight) { }
|
||||
|
||||
unsigned int GetSerializeSize(int nType, int nVersion) const {
|
||||
return ::GetSerializeSize(VARINT(nHeight*2+(fCoinBase ? 1 : 0)), nType, nVersion) +
|
||||
(nHeight > 0 ? ::GetSerializeSize(VARINT(this->nVersion), nType, nVersion) : 0) +
|
||||
return ::GetSerializeSize(VARINT(nHeight*4+(fCoinBase ? 2 : 0)+(fLastUnspent ? 1: 0)), nType, nVersion) +
|
||||
(fLastUnspent ? ::GetSerializeSize(VARINT(this->nVersion), nType, nVersion) : 0) +
|
||||
::GetSerializeSize(CTxOutCompressor(REF(txout)), nType, nVersion) +
|
||||
::GetSerializeSize(VARINT(nNCCValidHeight), nType, nVersion);
|
||||
}
|
||||
|
||||
template<typename Stream>
|
||||
void Serialize(Stream &s, int nType, int nVersion) const {
|
||||
::Serialize(s, VARINT(nHeight*2+(fCoinBase ? 1 : 0)), nType, nVersion);
|
||||
if (nHeight > 0)
|
||||
::Serialize(s, VARINT(nHeight*4+(fCoinBase ? 2 : 0)+(fLastUnspent ? 1: 0)), nType, nVersion);
|
||||
if (fLastUnspent)
|
||||
::Serialize(s, VARINT(this->nVersion), nType, nVersion);
|
||||
::Serialize(s, CTxOutCompressor(REF(txout)), nType, nVersion);
|
||||
::Serialize(s, VARINT(nNCCValidHeight), nType, nVersion);
|
||||
|
@ -49,9 +50,10 @@ public:
|
|||
void Unserialize(Stream &s, int nType, int nVersion) {
|
||||
unsigned int nCode = 0;
|
||||
::Unserialize(s, VARINT(nCode), nType, nVersion);
|
||||
nHeight = nCode / 2;
|
||||
fCoinBase = nCode & 1;
|
||||
if (nHeight > 0)
|
||||
nHeight = nCode / 4;
|
||||
fCoinBase = nCode & 2;
|
||||
fLastUnspent = nCode & 1;
|
||||
if (fLastUnspent)
|
||||
::Unserialize(s, VARINT(this->nVersion), nType, nVersion);
|
||||
::Unserialize(s, REF(CTxOutCompressor(REF(txout))), nType, nVersion);
|
||||
::Unserialize(s, VARINT(nNCCValidHeight), nType, nVersion);
|
||||
|
|
Loading…
Reference in a new issue