Compare commits

..

1 Commits

Author SHA1 Message Date
Valentin Balaschenko
7ce692db58 initial hash removal 2025-05-16 15:48:32 +01:00
12 changed files with 34 additions and 153 deletions

View File

@@ -9,7 +9,6 @@ target_compile_definitions (opts
BOOST_ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS
BOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT
BOOST_CONTAINER_FWD_BAD_DEQUE
BOOST_ASIO_ENABLE_HANDLER_TRACKING
HAS_UNCAUGHT_EXCEPTIONS=1
$<$<BOOL:${boost_show_deprecated}>:
BOOST_ASIO_NO_DEPRECATED

View File

@@ -157,48 +157,6 @@ private:
boost::filesystem::path m_path;
};
class AsioTrackingBuf : public std::streambuf
{
public:
explicit AsioTrackingBuf(beast::Journal j)
{
}
protected:
int
overflow(int ch) override
{
if (ch == '\n')
{
flush();
}
else if (ch != EOF)
{
buffer_ += static_cast<char>(ch);
}
return ch;
}
int
sync() override
{
flush();
return 0;
}
private:
void
flush()
{
if (!buffer_.empty())
{
buffer_.clear();
}
}
std::string buffer_;
};
std::mutex mutable mutex_;
std::map<
std::string,
@@ -208,8 +166,6 @@ private:
beast::severities::Severity thresh_;
File file_;
bool silent_ = false;
std::unique_ptr<AsioTrackingBuf> asioBuf_;
std::unique_ptr<std::ostream> asioStream_;
public:
Logs(beast::severities::Severity level);

View File

@@ -134,9 +134,6 @@ Logs::File::writeln(char const* text)
Logs::Logs(beast::severities::Severity thresh)
: thresh_(thresh) // default severity
{
asioBuf_ = std::make_unique<AsioTrackingBuf>(journal("AsioTracking"));
asioStream_ = std::make_unique<std::ostream>(asioBuf_.get());
std::clog.rdbuf(asioStream_->rdbuf());
}
bool

View File

@@ -580,21 +580,8 @@ PeerImp::close()
{
detaching_ = true; // DEPRECATED
error_code ec;
timer_.cancel(ec);
if (ec)
{
JLOG(journal_.info())
<< "PeerImp::close timer_.cancel ec: " << ec.message();
}
socket_.close(ec);
if (ec)
{
JLOG(journal_.info())
<< "PeerImp::close socket_.close ec: " << ec.message();
}
overlay_.incPeerDisconnect();
if (inbound_)
{
@@ -685,10 +672,6 @@ PeerImp::cancelTimer()
{
error_code ec;
timer_.cancel(ec);
if (ec)
{
JLOG(journal_.info()) << "PeerImp::cancelTimer ec: " << ec.message();
}
}
//------------------------------------------------------------------------------

View File

@@ -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

View File

@@ -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&

View File

@@ -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. */

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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");
}

View File

@@ -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);