mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Optimize peer I/O:
- Limit the lifetime of a buffer that was only used in the early phases of peer connection establishment but which lived on as long as the peer was active. - Cache the message used to transfer manifests, so it can be reused instead of recreated for every peer connection. - Improve the reading of partial messages by passing a hint to the I/O layer if the number of bytes needed to complete the message is known.
This commit is contained in:
@@ -1263,6 +1263,36 @@ OverlayImpl::relay(
|
||||
return {};
|
||||
}
|
||||
|
||||
std::shared_ptr<Message>
|
||||
OverlayImpl::getManifestsMessage()
|
||||
{
|
||||
std::lock_guard g(manifestLock_);
|
||||
|
||||
if (auto seq = app_.validatorManifests().sequence();
|
||||
seq != manifestListSeq_)
|
||||
{
|
||||
protocol::TMManifests tm;
|
||||
|
||||
app_.validatorManifests().for_each_manifest(
|
||||
[&tm](std::size_t s) { tm.mutable_list()->Reserve(s); },
|
||||
[&tm, &hr = app_.getHashRouter()](Manifest const& manifest) {
|
||||
tm.add_list()->set_stobject(
|
||||
manifest.serialized.data(), manifest.serialized.size());
|
||||
hr.addSuppression(manifest.hash());
|
||||
});
|
||||
|
||||
manifestMessage_.reset();
|
||||
|
||||
if (tm.list_size() != 0)
|
||||
manifestMessage_ =
|
||||
std::make_shared<Message>(tm, protocol::mtMANIFESTS);
|
||||
|
||||
manifestListSeq_ = seq;
|
||||
}
|
||||
|
||||
return manifestMessage_;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user