Compare commits

...

1 Commits

Author SHA1 Message Date
Bart
34de214d3e refactor: Use const function arguments where possible 2026-06-07 06:33:09 -04:00
13 changed files with 56 additions and 52 deletions

View File

@@ -53,7 +53,7 @@ public:
boost::system::error_code const& ecResult,
int iStatus,
std::string const& strData)> complete,
beast::Journal& j);
beast::Journal const& j);
static void
get(bool bSSL,
@@ -67,7 +67,7 @@ public:
boost::system::error_code const& ecResult,
int iStatus,
std::string const& strData)> complete,
beast::Journal& j);
beast::Journal const& j);
static void
request(
@@ -82,7 +82,7 @@ public:
boost::system::error_code const& ecResult,
int iStatus,
std::string const& strData)> complete,
beast::Journal& j);
beast::Journal const& j);
};
} // namespace xrpl

View File

@@ -161,7 +161,7 @@ public:
setLedgerSeq(std::uint32_t lseq);
bool
fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter);
fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter const* filter);
// normal hash access functions
@@ -248,7 +248,7 @@ public:
@param return The nodes known to be missing
*/
std::vector<std::pair<SHAMapNodeID, uint256>>
getMissingNodes(int maxNodes, SHAMapSyncFilter* filter);
getMissingNodes(int maxNodes, SHAMapSyncFilter const* filter);
bool
getNodeFat(
@@ -281,9 +281,9 @@ public:
serializeRoot(Serializer& s) const;
SHAMapAddNode
addRootNode(SHAMapHash const& hash, Slice const& rootNode, SHAMapSyncFilter* filter);
addRootNode(SHAMapHash const& hash, Slice const& rootNode, SHAMapSyncFilter const* filter);
SHAMapAddNode
addKnownNode(SHAMapNodeID const& nodeID, Slice const& rawNode, SHAMapSyncFilter* filter);
addKnownNode(SHAMapNodeID const& nodeID, Slice const& rawNode, SHAMapSyncFilter const* filter);
// status functions
void
@@ -343,11 +343,11 @@ private:
SHAMapTreeNodePtr
fetchNodeNT(SHAMapHash const& hash) const;
SHAMapTreeNodePtr
fetchNodeNT(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
fetchNodeNT(SHAMapHash const& hash, SHAMapSyncFilter const* filter) const;
SHAMapTreeNodePtr
fetchNode(SHAMapHash const& hash) const;
SHAMapTreeNodePtr
checkFilter(SHAMapHash const& hash, SHAMapSyncFilter* filter) const;
checkFilter(SHAMapHash const& hash, SHAMapSyncFilter const* filter) const;
/** Update hashes up to the root */
void
@@ -411,7 +411,7 @@ private:
descendAsync(
SHAMapInnerNode* parent,
int branch,
SHAMapSyncFilter* filter,
SHAMapSyncFilter const* filter,
bool& pending,
descendCallback&&) const;
@@ -420,7 +420,7 @@ private:
SHAMapInnerNode* parent,
SHAMapNodeID const& parentID,
int branch,
SHAMapSyncFilter* filter) const;
SHAMapSyncFilter const* filter) const;
// Non-storing
// Does not hook the returned node to its parent
@@ -461,7 +461,7 @@ private:
// basic parameters
int max;
SHAMapSyncFilter* filter;
SHAMapSyncFilter const* filter;
int const maxDefer;
std::uint32_t generation;
@@ -500,7 +500,11 @@ private:
// reads
std::map<SHAMapInnerNode*, SHAMapNodeID> resumes;
MissingNodes(int max, SHAMapSyncFilter* filter, int maxDefer, std::uint32_t generation)
MissingNodes(
int max,
SHAMapSyncFilter const* filter,
int maxDefer,
std::uint32_t generation)
: max(max), filter(filter), maxDefer(maxDefer), generation(generation), deferred(0)
{
missingNodes.reserve(max);

View File

@@ -64,7 +64,7 @@ public:
boost::asio::io_context& ioContext,
unsigned short const port,
std::size_t maxResponseSize,
beast::Journal& j)
beast::Journal const& j)
: socket_(
ioContext,
gHttpClientSslContext->context()) // NOLINT(bugprone-unchecked-optional-access)
@@ -552,7 +552,7 @@ HTTPClient::get(
std::function<
bool(boost::system::error_code const& ecResult, int iStatus, std::string const& strData)>
complete,
beast::Journal& j)
beast::Journal const& j)
{
auto client = std::make_shared<HTTPClientImp>(ioContext, port, responseMax, j);
client->get(bSSL, deqSites, strPath, timeout, complete);
@@ -570,7 +570,7 @@ HTTPClient::get(
std::function<
bool(boost::system::error_code const& ecResult, int iStatus, std::string const& strData)>
complete,
beast::Journal& j)
beast::Journal const& j)
{
std::deque<std::string> const deqSites(1, strSite);
@@ -590,7 +590,7 @@ HTTPClient::request(
std::function<
bool(boost::system::error_code const& ecResult, int iStatus, std::string const& strData)>
complete,
beast::Journal& j)
beast::Journal const& j)
{
std::deque<std::string> const deqSites(1, strSite);

View File

@@ -206,7 +206,7 @@ SHAMap::finishFetch(SHAMapHash const& hash, std::shared_ptr<NodeObject> const& o
// See if a sync filter has a node
SHAMapTreeNodePtr
SHAMap::checkFilter(SHAMapHash const& hash, SHAMapSyncFilter* filter) const
SHAMap::checkFilter(SHAMapHash const& hash, SHAMapSyncFilter const* filter) const
{
if (auto nodeData = filter->getNode(hash))
{
@@ -232,7 +232,7 @@ SHAMap::checkFilter(SHAMapHash const& hash, SHAMapSyncFilter* filter) const
// Get a node without throwing
// Used on maps where missing nodes are expected
SHAMapTreeNodePtr
SHAMap::fetchNodeNT(SHAMapHash const& hash, SHAMapSyncFilter* filter) const
SHAMap::fetchNodeNT(SHAMapHash const& hash, SHAMapSyncFilter const* filter) const
{
auto node = cacheLookup(hash);
if (node)
@@ -345,7 +345,7 @@ SHAMap::descend(
SHAMapInnerNode* parent,
SHAMapNodeID const& parentID,
int branch,
SHAMapSyncFilter* filter) const
SHAMapSyncFilter const* filter) const
{
XRPL_ASSERT(parent->isInner(), "xrpl::SHAMap::descend : valid parent input");
XRPL_ASSERT(
@@ -374,7 +374,7 @@ SHAMapTreeNode*
SHAMap::descendAsync(
SHAMapInnerNode* parent,
int branch,
SHAMapSyncFilter* filter,
SHAMapSyncFilter const* filter,
bool& pending,
descendCallback&& callback) const
{
@@ -885,7 +885,7 @@ SHAMap::updateGiveItem(SHAMapNodeType type, boost::intrusive_ptr<SHAMapItem cons
}
bool
SHAMap::fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter* filter)
SHAMap::fetchRoot(SHAMapHash const& hash, SHAMapSyncFilter const* filter)
{
if (hash == root_->getHash())
return true;

View File

@@ -305,7 +305,7 @@ SHAMap::gmnProcessDeferredReads(MissingNodes& mn)
nodes that are not permanently stored locally
*/
std::vector<std::pair<SHAMapNodeID, uint256>>
SHAMap::getMissingNodes(int max, SHAMapSyncFilter* filter)
SHAMap::getMissingNodes(int max, SHAMapSyncFilter const* filter)
{
XRPL_ASSERT(root_->getHash().isNonZero(), "xrpl::SHAMap::getMissingNodes : nonzero root hash");
XRPL_ASSERT(max > 0, "xrpl::SHAMap::getMissingNodes : valid max input");
@@ -507,7 +507,7 @@ SHAMap::serializeRoot(Serializer& s) const
}
SHAMapAddNode
SHAMap::addRootNode(SHAMapHash const& hash, Slice const& rootNode, SHAMapSyncFilter* filter)
SHAMap::addRootNode(SHAMapHash const& hash, Slice const& rootNode, SHAMapSyncFilter const* filter)
{
// we already have a root_ node
if (root_->getHash().isNonZero())
@@ -542,7 +542,7 @@ SHAMap::addRootNode(SHAMapHash const& hash, Slice const& rootNode, SHAMapSyncFil
}
SHAMapAddNode
SHAMap::addKnownNode(SHAMapNodeID const& node, Slice const& rawNode, SHAMapSyncFilter* filter)
SHAMap::addKnownNode(SHAMapNodeID const& node, Slice const& rawNode, SHAMapSyncFilter const* filter)
{
XRPL_ASSERT(!node.isRoot(), "xrpl::SHAMap::addKnownNode : valid node input");

View File

@@ -128,13 +128,13 @@ private:
pmDowncast() override;
int
processData(std::shared_ptr<Peer> peer, protocol::TMLedgerData& data);
processData(std::shared_ptr<Peer> peer, protocol::TMLedgerData const& data);
bool
takeHeader(std::string const& data);
void
receiveNode(protocol::TMLedgerData& packet, SHAMapAddNode&);
receiveNode(protocol::TMLedgerData const& packet, SHAMapAddNode&);
bool
takeTxRootNode(Slice const& data, SHAMapAddNode&);
@@ -143,10 +143,10 @@ private:
takeAsRootNode(Slice const& data, SHAMapAddNode&);
std::vector<uint256>
neededTxHashes(int max, SHAMapSyncFilter* filter) const;
neededTxHashes(int max, SHAMapSyncFilter const* filter) const;
std::vector<uint256>
neededStateHashes(int max, SHAMapSyncFilter* filter) const;
neededStateHashes(int max, SHAMapSyncFilter const* filter) const;
clock_type& clock_;
clock_type::time_point lastAction_;

View File

@@ -188,7 +188,7 @@ InboundLedger::~InboundLedger()
}
static std::vector<uint256>
neededHashes(uint256 const& root, SHAMap& map, int max, SHAMapSyncFilter* filter)
neededHashes(uint256 const& root, SHAMap& map, int max, SHAMapSyncFilter const* filter)
{
std::vector<uint256> ret;
@@ -211,13 +211,13 @@ neededHashes(uint256 const& root, SHAMap& map, int max, SHAMapSyncFilter* filter
}
std::vector<uint256>
InboundLedger::neededTxHashes(int max, SHAMapSyncFilter* filter) const
InboundLedger::neededTxHashes(int max, SHAMapSyncFilter const* filter) const
{
return neededHashes(ledger_->header().txHash, ledger_->txMap(), max, filter);
}
std::vector<uint256>
InboundLedger::neededStateHashes(int max, SHAMapSyncFilter* filter) const
InboundLedger::neededStateHashes(int max, SHAMapSyncFilter const* filter) const
{
return neededHashes(ledger_->header().accountHash, ledger_->stateMap(), max, filter);
}
@@ -820,7 +820,7 @@ InboundLedger::takeHeader(std::string const& data)
Call with a lock
*/
void
InboundLedger::receiveNode(protocol::TMLedgerData& packet, SHAMapAddNode& san)
InboundLedger::receiveNode(protocol::TMLedgerData const& packet, SHAMapAddNode& san)
{
if (!haveHeader_)
{
@@ -1026,7 +1026,7 @@ InboundLedger::gotData(
// TODO Change peer to Consumer
//
int
InboundLedger::processData(std::shared_ptr<Peer> peer, protocol::TMLedgerData& packet)
InboundLedger::processData(std::shared_ptr<Peer> peer, protocol::TMLedgerData const& packet)
{
if (packet.type() == protocol::liBASE)
{

View File

@@ -492,7 +492,7 @@ public:
void
run() override;
void
signalStop(std::string msg) override;
signalStop(std::string const& msg) override;
bool
checkSigs() const override;
void
@@ -1602,7 +1602,7 @@ ApplicationImp::run()
}
void
ApplicationImp::signalStop(std::string msg)
ApplicationImp::signalStop(std::string const& msg)
{
if (!isTimeToStop.test_and_set(std::memory_order_acquire))
{

View File

@@ -111,7 +111,7 @@ public:
virtual void
run() = 0;
virtual void
signalStop(std::string msg) = 0;
signalStop(std::string const& msg) = 0;
[[nodiscard]] virtual bool
checkSigs() const = 0;
virtual void

View File

@@ -693,7 +693,7 @@ public:
validationSET_EXPIRES ago and were not asked to keep.
*/
void
expire(beast::Journal& j)
expire(beast::Journal const& j)
{
auto const start = std::chrono::steady_clock::now();
{

View File

@@ -117,11 +117,11 @@ public:
/** Broadcast a proposal. */
virtual void
broadcast(protocol::TMProposeSet& m) = 0;
broadcast(protocol::TMProposeSet const& m) = 0;
/** Broadcast a validation. */
virtual void
broadcast(protocol::TMValidation& m) = 0;
broadcast(protocol::TMValidation const& m) = 0;
/** Relay a proposal.
* @param m the serialized proposal
@@ -130,7 +130,7 @@ public:
* @return the set of peers which have already sent us this proposal
*/
virtual std::set<Peer::id_t>
relay(protocol::TMProposeSet& m, uint256 const& uid, PublicKey const& validator) = 0;
relay(protocol::TMProposeSet const& m, uint256 const& uid, PublicKey const& validator) = 0;
/** Relay a validation.
* @param m the serialized validation
@@ -139,7 +139,7 @@ public:
* @return the set of peers which have already sent us this validation
*/
virtual std::set<Peer::id_t>
relay(protocol::TMValidation& m, uint256 const& uid, PublicKey const& validator) = 0;
relay(protocol::TMValidation const& m, uint256 const& uid, PublicKey const& validator) = 0;
/** Relay a transaction. If the tx reduce-relay feature is enabled then
* randomly select peers to relay to and queue transaction's hash

View File

@@ -407,7 +407,7 @@ OverlayImpl::makeErrorResponse(
std::shared_ptr<PeerFinder::Slot> const& slot,
http_request_type const& request,
address_type remoteAddress,
std::string text)
std::string const& text)
{
boost::beast::http::response<boost::beast::http::empty_body> msg;
msg.version(request.version());
@@ -1157,14 +1157,14 @@ OverlayImpl::findPeerByPublicKey(PublicKey const& pubKey)
}
void
OverlayImpl::broadcast(protocol::TMProposeSet& m)
OverlayImpl::broadcast(protocol::TMProposeSet const& m)
{
auto const sm = std::make_shared<Message>(m, protocol::mtPROPOSE_LEDGER);
forEach([&](std::shared_ptr<PeerImp> const& p) { p->send(sm); });
}
std::set<Peer::id_t>
OverlayImpl::relay(protocol::TMProposeSet& m, uint256 const& uid, PublicKey const& validator)
OverlayImpl::relay(protocol::TMProposeSet const& m, uint256 const& uid, PublicKey const& validator)
{
if (auto const toSkip = app_.getHashRouter().shouldRelay(uid))
{
@@ -1179,14 +1179,14 @@ OverlayImpl::relay(protocol::TMProposeSet& m, uint256 const& uid, PublicKey cons
}
void
OverlayImpl::broadcast(protocol::TMValidation& m)
OverlayImpl::broadcast(protocol::TMValidation const& m)
{
auto const sm = std::make_shared<Message>(m, protocol::mtVALIDATION);
forEach([sm](std::shared_ptr<PeerImp> const& p) { p->send(sm); });
}
std::set<Peer::id_t>
OverlayImpl::relay(protocol::TMValidation& m, uint256 const& uid, PublicKey const& validator)
OverlayImpl::relay(protocol::TMValidation const& m, uint256 const& uid, PublicKey const& validator)
{
if (auto const toSkip = app_.getHashRouter().shouldRelay(uid))
{

View File

@@ -202,16 +202,16 @@ public:
findPeerByPublicKey(PublicKey const& pubKey) override;
void
broadcast(protocol::TMProposeSet& m) override;
broadcast(protocol::TMProposeSet const& m) override;
void
broadcast(protocol::TMValidation& m) override;
broadcast(protocol::TMValidation const& m) override;
std::set<Peer::id_t>
relay(protocol::TMProposeSet& m, uint256 const& uid, PublicKey const& validator) override;
relay(protocol::TMProposeSet const& m, uint256 const& uid, PublicKey const& validator) override;
std::set<Peer::id_t>
relay(protocol::TMValidation& m, uint256 const& uid, PublicKey const& validator) override;
relay(protocol::TMValidation const& m, uint256 const& uid, PublicKey const& validator) override;
void
relay(
@@ -433,7 +433,7 @@ private:
std::shared_ptr<PeerFinder::Slot> const& slot,
http_request_type const& request,
address_type remoteAddress,
std::string msg);
std::string const& msg);
/** Handles crawl requests. Crawl returns information about the
node and its peers so crawlers can map the network.