From b52f47f273666036ee7bb6fda3925066cd543395 Mon Sep 17 00:00:00 2001 From: Brannon King Date: Wed, 28 Aug 2019 14:04:29 -0600 Subject: [PATCH] removed shared_ptr on TData, set minWork --- src/chainparams.cpp | 5 ++--- src/claimtrie.h | 2 +- src/prefixtrie.cpp | 25 +++++++++++-------------- src/prefixtrie.h | 2 +- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index dd9b33ab5..073000f72 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -165,11 +165,10 @@ public: consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1548288000; // Jan 24, 2019 // The best chain should have at least this much work. - consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000000607ca7e806c4c1e9"); //400000 + consensus.nMinimumChainWork = uint256S("00000000000000000000000000000000000000000000024108e3204a44a57a5a"); //621000 // By default assume that the signatures in ancestors of this block are valid. - //consensus.defaultAssumeValid = uint256S("0xf0e56e70782af63ccb49c76e852540688755869ba59ec68cac9c04a6b4d9f5ca"); //400000 - consensus.defaultAssumeValid = uint256S("0xa6bbb48f5343eb9b0287c22f3ea8b29f36cf10794a37f8a925a894d6f4519913"); //4000 + consensus.defaultAssumeValid = uint256S("7899464514d0d8854919e87eb234fd5f0c35d06418bd5fd3c1a8f7092b2a9317"); //620000 /** * The message start string is designed to be unlikely to occur in normal data. diff --git a/src/claimtrie.h b/src/claimtrie.h index e8b5d3471..f39fd32a5 100644 --- a/src/claimtrie.h +++ b/src/claimtrie.h @@ -148,8 +148,8 @@ struct CClaimTrieData int nHeightOfLastTakeover = 0; // non-serialized data: - uint256 hash; uint32_t flags = 0; + uint256 hash; CClaimTrieData() = default; CClaimTrieData(CClaimTrieData&&) = default; diff --git a/src/prefixtrie.cpp b/src/prefixtrie.cpp index 1dc832b1e..3793523f1 100644 --- a/src/prefixtrie.cpp +++ b/src/prefixtrie.cpp @@ -109,7 +109,7 @@ template typename CPrefixTrie::template Iterator::reference CPrefixTrie::Iterator::operator*() const { assert(!node.expired()); - return TPair(name, *(node.lock()->data)); + return TPair(name, node.lock()->data); } template @@ -117,7 +117,7 @@ template typename CPrefixTrie::template Iterator::pointer CPrefixTrie::Iterator::operator->() const { assert(!node.expired()); - return node.lock()->data.get(); + return &(node.lock()->data); } template @@ -132,7 +132,7 @@ template TData& CPrefixTrie::Iterator::data() { assert(!node.expired()); - return *(node.lock()->data); + return node.lock()->data; } template @@ -140,7 +140,7 @@ template const TData& CPrefixTrie::Iterator::data() const { assert(!node.expired()); - return *(node.lock()->data); + return node.lock()->data; } template @@ -223,7 +223,6 @@ std::shared_ptr::Node>& CPrefixTrie()).first; - it->second->data = std::make_shared(); return it->second; } if (count < it->first.size()) { @@ -234,7 +233,6 @@ std::shared_ptr::Node>& CPrefixTrie()).first; it->second->children.emplace(postfix, std::move(nodes)); - it->second->data = std::make_shared(); if (key.size() == count) return it->second; } @@ -253,12 +251,12 @@ void CPrefixTrie::erase(const TKey& key, std::shared_ptr& nod if (!find(key, node, cb)) return; - nodes.back().second->data = std::make_shared(); + nodes.back().second->data = {}; for (; nodes.size() > 1; nodes.pop_back()) { // if we have only one child and no data ourselves, bring them up to our level auto& cNode = nodes.back().second; auto onlyOneChild = cNode->children.size() == 1; - auto noData = cNode->data->empty(); + auto noData = cNode->data.empty(); if (onlyOneChild && noData) { auto child = cNode->children.begin(); auto& prefix = nodes.back().first; @@ -286,7 +284,6 @@ void CPrefixTrie::erase(const TKey& key, std::shared_ptr& nod template CPrefixTrie::CPrefixTrie() : size(0), root(std::make_shared()) { - root->data = std::make_shared(); } template @@ -294,7 +291,7 @@ template typename CPrefixTrie::iterator CPrefixTrie::insert(const TKey& key, TDataUni&& data) { auto& node = key.empty() ? root : insert(key, root); - node->data = std::make_shared(std::forward(data)); + node->data = std::forward(data); return key.empty() ? begin() : iterator{key, node}; } @@ -320,7 +317,7 @@ typename CPrefixTrie::iterator CPrefixTrie::insert(CPr auto& node = insert(key, shared); copy = iterator{name, node}; } - copy.node.lock()->data = std::make_shared(std::forward(data)); + copy.node.lock()->data = std::forward(data); return copy; } @@ -393,7 +390,7 @@ bool CPrefixTrie::erase(const TKey& key) { auto size_was = height(); if (key.empty()) { - root->data = std::make_shared(); + root->data = {}; } else { erase(key, root); } @@ -404,7 +401,7 @@ template void CPrefixTrie::clear() { size = 0; - root->data = std::make_shared(); + root->data = {}; root->children.clear(); } @@ -417,7 +414,7 @@ bool CPrefixTrie::empty() const template std::size_t CPrefixTrie::height() const { - return size + (root->data->empty() ? 0 : 1); + return size + (root->data.empty() ? 0 : 1); } template diff --git a/src/prefixtrie.h b/src/prefixtrie.h index 559eefd48..142ec4e9d 100644 --- a/src/prefixtrie.h +++ b/src/prefixtrie.h @@ -29,7 +29,7 @@ class CPrefixTrie Node(Node&& o) noexcept = default; Node& operator=(Node&& o) noexcept = default; Node& operator=(const Node&) = delete; - std::shared_ptr data; + TData data; }; using TChildren = decltype(Node::children);