mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-04 19:25:51 +00:00
Compare commits
1 Commits
Bronek/add
...
vlntb/remo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ce692db58 |
@@ -43,19 +43,10 @@ public:
|
||||
updateHash();
|
||||
}
|
||||
|
||||
SHAMapAccountStateLeafNode(
|
||||
boost::intrusive_ptr<SHAMapItem const> item,
|
||||
std::uint32_t cowid,
|
||||
SHAMapHash const& hash)
|
||||
: SHAMapLeafNode(std::move(item), cowid, hash)
|
||||
{
|
||||
}
|
||||
|
||||
intr_ptr::SharedPtr<SHAMapTreeNode>
|
||||
clone(std::uint32_t cowid) const final override
|
||||
{
|
||||
return intr_ptr::make_shared<SHAMapAccountStateLeafNode>(
|
||||
item_, cowid, hash_);
|
||||
return intr_ptr::make_shared<SHAMapAccountStateLeafNode>(item_, cowid);
|
||||
}
|
||||
|
||||
SHAMapNodeType
|
||||
@@ -67,8 +58,11 @@ public:
|
||||
void
|
||||
updateHash() final override
|
||||
{
|
||||
hash_ = SHAMapHash{
|
||||
sha512Half(HashPrefix::leafNode, item_->slice(), item_->key())};
|
||||
// hash_ = SHAMapHash{
|
||||
// sha512Half(HashPrefix::leafNode, item_->slice(), item_->key())};
|
||||
|
||||
// TODO return SHAMapHash{
|
||||
// sha512Half(HashPrefix::leafNode, item_->slice(), item_->key())};
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -36,11 +36,6 @@ protected:
|
||||
boost::intrusive_ptr<SHAMapItem const> item,
|
||||
std::uint32_t cowid);
|
||||
|
||||
SHAMapLeafNode(
|
||||
boost::intrusive_ptr<SHAMapItem const> item,
|
||||
std::uint32_t cowid,
|
||||
SHAMapHash const& hash);
|
||||
|
||||
public:
|
||||
SHAMapLeafNode(const SHAMapLeafNode&) = delete;
|
||||
SHAMapLeafNode&
|
||||
|
||||
@@ -51,8 +51,6 @@ enum class SHAMapNodeType {
|
||||
class SHAMapTreeNode : public IntrusiveRefCounts
|
||||
{
|
||||
protected:
|
||||
SHAMapHash hash_;
|
||||
|
||||
/** Determines the owning SHAMap, if any. Used for copy-on-write semantics.
|
||||
|
||||
If this value is 0, the node is not dirty and does not need to be
|
||||
@@ -75,13 +73,6 @@ protected:
|
||||
explicit SHAMapTreeNode(std::uint32_t cowid) noexcept : cowid_(cowid)
|
||||
{
|
||||
}
|
||||
|
||||
explicit SHAMapTreeNode(
|
||||
std::uint32_t cowid,
|
||||
SHAMapHash const& hash) noexcept
|
||||
: hash_(hash), cowid_(cowid)
|
||||
{
|
||||
}
|
||||
/** @} */
|
||||
|
||||
public:
|
||||
@@ -144,7 +135,9 @@ public:
|
||||
SHAMapHash const&
|
||||
getHash() const
|
||||
{
|
||||
return hash_;
|
||||
// TODO
|
||||
static SHAMapHash s;
|
||||
return s;
|
||||
}
|
||||
|
||||
/** Determines the type of node. */
|
||||
|
||||
@@ -42,18 +42,10 @@ public:
|
||||
updateHash();
|
||||
}
|
||||
|
||||
SHAMapTxLeafNode(
|
||||
boost::intrusive_ptr<SHAMapItem const> item,
|
||||
std::uint32_t cowid,
|
||||
SHAMapHash const& hash)
|
||||
: SHAMapLeafNode(std::move(item), cowid, hash)
|
||||
{
|
||||
}
|
||||
|
||||
intr_ptr::SharedPtr<SHAMapTreeNode>
|
||||
clone(std::uint32_t cowid) const final override
|
||||
{
|
||||
return intr_ptr::make_shared<SHAMapTxLeafNode>(item_, cowid, hash_);
|
||||
return intr_ptr::make_shared<SHAMapTxLeafNode>(item_, cowid);
|
||||
}
|
||||
|
||||
SHAMapNodeType
|
||||
@@ -65,8 +57,8 @@ public:
|
||||
void
|
||||
updateHash() final override
|
||||
{
|
||||
hash_ =
|
||||
SHAMapHash{sha512Half(HashPrefix::transactionID, item_->slice())};
|
||||
// hash_ =
|
||||
// SHAMapHash{sha512Half(HashPrefix::transactionID, item_->slice())};
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -43,19 +43,10 @@ public:
|
||||
updateHash();
|
||||
}
|
||||
|
||||
SHAMapTxPlusMetaLeafNode(
|
||||
boost::intrusive_ptr<SHAMapItem const> item,
|
||||
std::uint32_t cowid,
|
||||
SHAMapHash const& hash)
|
||||
: SHAMapLeafNode(std::move(item), cowid, hash)
|
||||
{
|
||||
}
|
||||
|
||||
intr_ptr::SharedPtr<SHAMapTreeNode>
|
||||
clone(std::uint32_t cowid) const override
|
||||
{
|
||||
return intr_ptr::make_shared<SHAMapTxPlusMetaLeafNode>(
|
||||
item_, cowid, hash_);
|
||||
return intr_ptr::make_shared<SHAMapTxPlusMetaLeafNode>(item_, cowid);
|
||||
}
|
||||
|
||||
SHAMapNodeType
|
||||
@@ -67,8 +58,8 @@ public:
|
||||
void
|
||||
updateHash() final override
|
||||
{
|
||||
hash_ = SHAMapHash{
|
||||
sha512Half(HashPrefix::txNode, item_->slice(), item_->key())};
|
||||
// hash_ = SHAMapHash{
|
||||
// sha512Half(HashPrefix::txNode, item_->slice(), item_->key())};
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -83,7 +83,6 @@ SHAMapInnerNode::clone(std::uint32_t cowid) const
|
||||
auto const branchCount = getBranchCount();
|
||||
auto const thisIsSparse = !hashesAndChildren_.isDense();
|
||||
auto p = intr_ptr::make_shared<SHAMapInnerNode>(cowid, branchCount);
|
||||
p->hash_ = hash_;
|
||||
p->isBranch_ = isBranch_;
|
||||
p->fullBelowGen_ = fullBelowGen_;
|
||||
SHAMapHash *cloneHashes, *thisHashes;
|
||||
@@ -154,10 +153,11 @@ SHAMapInnerNode::makeFullInner(
|
||||
|
||||
ret->resizeChildArrays(ret->getBranchCount());
|
||||
|
||||
if (hashValid)
|
||||
ret->hash_ = hash;
|
||||
else
|
||||
ret->updateHash();
|
||||
// TODO: do this outside?
|
||||
// if (hashValid)
|
||||
// ret->hash_ = hash;
|
||||
// else
|
||||
// ret->updateHash();
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -210,7 +210,9 @@ SHAMapInnerNode::updateHash()
|
||||
iterChildren([&](SHAMapHash const& hh) { hash_append(h, hh); });
|
||||
nh = static_cast<typename sha512_half_hasher::result_type>(h);
|
||||
}
|
||||
hash_ = SHAMapHash{nh};
|
||||
|
||||
// TODO return SHAMapHash{nh};
|
||||
// hash_ = SHAMapHash{nh};
|
||||
}
|
||||
|
||||
void
|
||||
@@ -314,8 +316,6 @@ SHAMapInnerNode::setChild(int m, intr_ptr::SharedPtr<SHAMapTreeNode> child)
|
||||
children[childIndex] = std::move(child);
|
||||
}
|
||||
|
||||
hash_.zero();
|
||||
|
||||
XRPL_ASSERT(
|
||||
getBranchCount() <= hashesAndChildren_.capacity(),
|
||||
"ripple::SHAMapInnerNode::setChild : maximum branch count");
|
||||
@@ -472,15 +472,9 @@ SHAMapInnerNode::invariants(bool is_root) const
|
||||
|
||||
if (!is_root)
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
hash_.isNonZero(),
|
||||
"ripple::SHAMapInnerNode::invariants : nonzero hash");
|
||||
XRPL_ASSERT(
|
||||
count >= 1, "ripple::SHAMapInnerNode::invariants : minimum count");
|
||||
}
|
||||
XRPL_ASSERT(
|
||||
(count == 0) ? hash_.isZero() : hash_.isNonZero(),
|
||||
"ripple::SHAMapInnerNode::invariants : hash and count do match");
|
||||
}
|
||||
|
||||
} // namespace ripple
|
||||
|
||||
@@ -32,19 +32,6 @@ SHAMapLeafNode::SHAMapLeafNode(
|
||||
"SHAMapItem const>, std::uint32_t) : minimum input size");
|
||||
}
|
||||
|
||||
SHAMapLeafNode::SHAMapLeafNode(
|
||||
boost::intrusive_ptr<SHAMapItem const> item,
|
||||
std::uint32_t cowid,
|
||||
SHAMapHash const& hash)
|
||||
: SHAMapTreeNode(cowid, hash), item_(std::move(item))
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
item_->size() >= 12,
|
||||
"ripple::SHAMapLeafNode::SHAMapLeafNode(boost::intrusive_ptr<"
|
||||
"SHAMapItem const>, std::uint32_t, SHAMapHash const&) : minimum input "
|
||||
"size");
|
||||
}
|
||||
|
||||
boost::intrusive_ptr<SHAMapItem const> const&
|
||||
SHAMapLeafNode::peekItem() const
|
||||
{
|
||||
@@ -57,11 +44,14 @@ SHAMapLeafNode::setItem(boost::intrusive_ptr<SHAMapItem const> item)
|
||||
XRPL_ASSERT(cowid_, "ripple::SHAMapLeafNode::setItem : nonzero cowid");
|
||||
item_ = std::move(item);
|
||||
|
||||
auto const oldHash = hash_;
|
||||
// auto const oldHash = hash_;
|
||||
|
||||
updateHash();
|
||||
// updateHash();
|
||||
|
||||
return (oldHash != hash_);
|
||||
// return (oldHash != hash_);
|
||||
|
||||
// TODO : return updateHash();
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string
|
||||
@@ -82,8 +72,8 @@ SHAMapLeafNode::getString(const SHAMapNodeID& id) const
|
||||
|
||||
ret += " Tag=";
|
||||
ret += to_string(item_->key());
|
||||
ret += "\n Hash=";
|
||||
ret += to_string(hash_);
|
||||
// ret += "\n Hash=";
|
||||
// ret += to_string(hash_);
|
||||
ret += "/";
|
||||
ret += std::to_string(item_->size());
|
||||
return ret;
|
||||
@@ -92,8 +82,6 @@ SHAMapLeafNode::getString(const SHAMapNodeID& id) const
|
||||
void
|
||||
SHAMapLeafNode::invariants(bool) const
|
||||
{
|
||||
XRPL_ASSERT(
|
||||
hash_.isNonZero(), "ripple::SHAMapLeafNode::invariants : nonzero hash");
|
||||
XRPL_ASSERT(item_, "ripple::SHAMapLeafNode::invariants : non-null item");
|
||||
}
|
||||
|
||||
|
||||
@@ -42,8 +42,7 @@ SHAMapTreeNode::makeTransaction(
|
||||
make_shamapitem(sha512Half(HashPrefix::transactionID, data), data);
|
||||
|
||||
if (hashValid)
|
||||
return intr_ptr::make_shared<SHAMapTxLeafNode>(
|
||||
std::move(item), 0, hash);
|
||||
return intr_ptr::make_shared<SHAMapTxLeafNode>(std::move(item), 0);
|
||||
|
||||
return intr_ptr::make_shared<SHAMapTxLeafNode>(std::move(item), 0);
|
||||
}
|
||||
@@ -72,7 +71,7 @@ SHAMapTreeNode::makeTransactionWithMeta(
|
||||
|
||||
if (hashValid)
|
||||
return intr_ptr::make_shared<SHAMapTxPlusMetaLeafNode>(
|
||||
std::move(item), 0, hash);
|
||||
std::move(item), 0);
|
||||
|
||||
return intr_ptr::make_shared<SHAMapTxPlusMetaLeafNode>(std::move(item), 0);
|
||||
}
|
||||
@@ -104,7 +103,7 @@ SHAMapTreeNode::makeAccountState(
|
||||
|
||||
if (hashValid)
|
||||
return intr_ptr::make_shared<SHAMapAccountStateLeafNode>(
|
||||
std::move(item), 0, hash);
|
||||
std::move(item), 0);
|
||||
|
||||
return intr_ptr::make_shared<SHAMapAccountStateLeafNode>(
|
||||
std::move(item), 0);
|
||||
|
||||
Reference in New Issue
Block a user