Skip to content

Commit

Permalink
DEBUG DEVELOP
Browse files Browse the repository at this point in the history
  • Loading branch information
pwojcikdev committed Mar 16, 2024
1 parent ef985e3 commit e010105
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions nano/node/transport/tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,10 @@ std::unordered_set<std::shared_ptr<nano::transport::channel>> nano::transport::t
for (auto i (0); i < random_cutoff && result.size () < count_a; ++i)
{
auto index (nano::random_pool::generate_word32 (0, static_cast<CryptoPP::word32> (peers_size - 1)));
release_assert (index < channels.size ());

auto channel = channels.get<random_access_tag> ()[index].channel;
release_assert (channel != nullptr);
if (!channel->alive ())
{
continue;
Expand Down Expand Up @@ -588,11 +590,15 @@ void nano::transport::tcp_channels::ongoing_merge (size_t channel_index, nano::k
void nano::transport::tcp_channels::list (std::deque<std::shared_ptr<nano::transport::channel>> & deque_a, uint8_t minimum_version_a, bool include_temporary_channels_a)
{
nano::lock_guard<nano::mutex> lock{ mutex };
// clang-format off
nano::transform_if (channels.get<random_access_tag> ().begin (), channels.get<random_access_tag> ().end (), std::back_inserter (deque_a),
[include_temporary_channels_a, minimum_version_a](auto & channel_a) { return channel_a.channel->get_network_version () >= minimum_version_a && (include_temporary_channels_a || !channel_a.channel->temporary); },
[](auto const & channel) { return channel.channel; });
// clang-format on

nano::transform_if (
channels.get<random_access_tag> ().begin (), channels.get<random_access_tag> ().end (), std::back_inserter (deque_a),
[include_temporary_channels_a, minimum_version_a] (auto & channel_a) {
release_assert (channel_a.channel != nullptr);
return channel_a.channel->get_network_version () >= minimum_version_a && (include_temporary_channels_a || !channel_a.channel->temporary); },
[] (auto const & channel) {
return channel.channel;
});
}

void nano::transport::tcp_channels::modify (std::shared_ptr<nano::transport::channel_tcp> const & channel_a, std::function<void (std::shared_ptr<nano::transport::channel_tcp> const &)> modify_callback_a)
Expand Down

0 comments on commit e010105

Please sign in to comment.