Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix & refactor bootstrap_server #3861

Merged
merged 12 commits into from
Aug 6, 2022

Conversation

pwojcikdev
Copy link
Contributor

No description provided.

@pwojcikdev pwojcikdev added bug quality improvements This item indicates the need for or supplies changes that improve maintainability labels Jul 18, 2022
if (error)
{
status = parse_status::invalid_header;
callback (boost::system::error_code{}, nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These look like they should be passing in error codes, at the least boost::asio::error::fault

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about passing in error codes, but passing in asio::fault seems wrong as this is not an asio fault. The appropriate thing to do would be to create a nano::error_code::deserialization_error but I didn't think it was worth the effort. Will investigate how to do that.

nano/node/common.cpp Outdated Show resolved Hide resolved
nano/node/bootstrap/message_deserializer.cpp Show resolved Hide resolved
nano/node/bootstrap/message_deserializer.cpp Outdated Show resolved Hide resolved
nano/node/bootstrap/message_deserializer.cpp Outdated Show resolved Hide resolved
nano/node/bootstrap/message_deserializer.cpp Outdated Show resolved Hide resolved
nano/node/bootstrap/message_deserializer.cpp Outdated Show resolved Hide resolved
}

void nano::bootstrap_server::run_next (nano::unique_lock<nano::mutex> & lock_a)
bool nano::bootstrap_server::to_realtime_connection (nano::account const & node_id)
Copy link
Contributor

@clemahieu clemahieu Jul 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To match other code an error code is signalled by returning true, success == 0 == false.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that convention very misleading, seems like a low level C legacy. Let's say we have a check for success using the false for indicating that: 'if !operation_successful())' that reads "if not operation successful" which is logically the opposite of what we want. Needless cognitive overhead in my opinion.

{
switch (type)
{
case nano::socket::type_t::undefined:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency this should be renamed to handshake rather than undefined since it's referenced by is_handshake_connection.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But calling it handshake would be incorrect for bootstrap connections. Wouldn't it?
We could possibly have an additional state calling handshake when we have started a handshake but before completing it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think is_handshake_connection() should be renamed to is_undefined_connection() because that is exactly what it is checking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be renamed, it's true that there won't be any handshake if the connection is used for bootstrapping. I would move the whole socket type tracking into bootstrap_server (and rename that to network_server) because at the end of the day socket should be oblivious as to what it's used for, this is the task for higher layers

@pwojcikdev pwojcikdev force-pushed the bootstrap-server-fix-1 branch 6 times, most recently from 49296cb to 1a21512 Compare July 20, 2022 16:29
dsiganos
dsiganos previously approved these changes Aug 5, 2022
@pwojcikdev pwojcikdev merged commit 692f89b into nanocurrency:develop Aug 6, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug quality improvements This item indicates the need for or supplies changes that improve maintainability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants