Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/5.0' into p2p-peer-throt…
Browse files Browse the repository at this point in the history
…tle-main
  • Loading branch information
heifner committed Oct 10, 2023
2 parents 3470458 + 1498a04 commit 1db67f7
Show file tree
Hide file tree
Showing 16 changed files with 924 additions and 237 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class bp_connection_manager {
// Only called from connection strand
std::size_t num_established_clients() const {
uint32_t num_clients = 0;
self()->connections.for_each_connection([&num_clients](auto&& conn) {
self()->connections.for_each_connection([&num_clients](const std::shared_ptr<Connection>& conn) {
if (established_client_connection(conn)) {
++num_clients;
}
Expand All @@ -157,7 +157,7 @@ class bp_connection_manager {
// Only called from connection strand
// This should only be called after the first handshake message is received to check if an incoming connection
// has exceeded the pre-configured max_client_count limit.
bool exceeding_connection_limit(Connection* new_connection) const {
bool exceeding_connection_limit(std::shared_ptr<Connection> new_connection) const {
return auto_bp_peering_enabled() && self()->connections.get_max_client_count() != 0 &&
established_client_connection(new_connection) && num_established_clients() > self()->connections.get_max_client_count();
}
Expand All @@ -182,7 +182,7 @@ class bp_connection_manager {

fc_dlog(self()->get_logger(), "pending_downstream_neighbors: ${pending_downstream_neighbors}",
("pending_downstream_neighbors", to_string(pending_downstream_neighbors)));
for (auto neighbor : pending_downstream_neighbors) { self()->connections.connect(config.bp_peer_addresses[neighbor], *self()->p2p_addresses.begin() ); }
for (auto neighbor : pending_downstream_neighbors) { self()->connections.resolve_and_connect(config.bp_peer_addresses[neighbor], self()->get_first_p2p_address() ); }

pending_neighbors = std::move(pending_downstream_neighbors);
finder.add_upstream_neighbors(pending_neighbors);
Expand Down
3 changes: 3 additions & 0 deletions plugins/net_plugin/include/eosio/net_plugin/net_plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ namespace eosio {
std::chrono::nanoseconds last_bytes_received{0};
size_t bytes_sent{0};
std::chrono::nanoseconds last_bytes_sent{0};
size_t block_sync_bytes_received{0};
size_t block_sync_bytes_sent{0};
bool block_sync_throttling{false};
std::chrono::nanoseconds connection_start_time{0};
std::string log_p2p_address;
};
Expand Down
4 changes: 3 additions & 1 deletion plugins/net_plugin/include/eosio/net_plugin/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ namespace eosio {

// Longest domain name is 253 characters according to wikipedia.
// Addresses include ":port" where max port is 65535, which adds 6 chars.
// Addresses may also include ":bitrate" with suffix and separators, which adds 30 chars,
// for the maximum comma-separated value that fits in a size_t expressed in decimal plus a suffix.
// We also add our own extentions of "[:trx|:blk] - xxxxxxx", which adds 14 chars, total= 273.
// Allow for future extentions as well, hence 384.
constexpr size_t max_p2p_address_length = 253 + 6;
constexpr size_t max_p2p_address_length = 253 + 6 + 30;
constexpr size_t max_handshake_str_length = 384;

struct handshake_message {
Expand Down
Loading

0 comments on commit 1db67f7

Please sign in to comment.