Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Remove Channel::remote_node_name_ #14

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions mage/core/channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,8 @@ void Channel::Start() {
io_task_loop_.WatchSocket(this);
}

void Channel::SetRemoteNodeName(const std::string& name) {
CHECK_ON_THREAD(base::ThreadType::UI);
remote_node_name_ = name;
}

void Channel::SendInvitation(std::string inviter_name,
std::string temporary_remote_node_name,
std::string intended_endpoint_peer_name) {
CHECK_ON_THREAD(base::ThreadType::UI);
Message message(MessageType::SEND_INVITATION);
Expand All @@ -91,8 +87,8 @@ void Channel::SendInvitation(std::string inviter_name,
inviter_name.size());

// Serialize temporary remote node name.
memcpy(params.data()->temporary_remote_node_name, remote_node_name_.c_str(),
remote_node_name_.size());
memcpy(params.data()->temporary_remote_node_name,
temporary_remote_node_name.c_str(), temporary_remote_node_name.size());

// Serialize intended endpoint peer name.
memcpy(params.data()->intended_endpoint_peer_name,
Expand Down
5 changes: 1 addition & 4 deletions mage/core/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Channel : public base::TaskLoopForIO::SocketReader {
void Start();
void SetRemoteNodeName(const std::string& name);
void SendInvitation(std::string inviter_name,
std::string temporary_remote_node_name,
std::string intended_endpoint_peer_name);
void SendAcceptInvitation(std::string temporary_remote_node_name,
std::string actual_node_name,
Expand All @@ -35,10 +36,6 @@ class Channel : public base::TaskLoopForIO::SocketReader {
void OnCanReadFromSocket() override;

private:
// This is always initialized as something temporary until we hear back from
// the remote node and it tells us its name.
std::string remote_node_name_;

// The |Delegate| owns |this|, so this pointer will never be null.
Delegate* delegate_;

Expand Down
2 changes: 1 addition & 1 deletion mage/core/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ MessagePipe Node::SendInvitationAndGetMessagePipe(int fd) {
// expensive, and we can avoid it with one-time proper ordering.
std::unique_ptr<Channel>& channel = it.first->second;
channel->Start();
channel->SetRemoteNodeName(temporary_remote_node_name);
channel->SendInvitation(/*inviter_name=*/name_,
/*temporary_remote_node_name=*/temporary_remote_node_name,
/*intended_endpoint_peer_name=*/
remote_endpoint->peer_address.endpoint_name);

Expand Down