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