Skip to content

Commit

Permalink
Remove Channel::remote_node_name_ (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
domfarolino authored Aug 24, 2023
1 parent b7ba636 commit 6f81b18
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
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

0 comments on commit 6f81b18

Please sign in to comment.