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

Change the way to get RemoteNode from ActorSelection to RemoteNodes Dictionary #1354

Merged
merged 6 commits into from
Dec 18, 2019
Merged
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
22 changes: 12 additions & 10 deletions src/neo/Network/P2P/LocalNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,17 @@ private void BroadcastMessage(MessageCommand command, ISerializable payload = nu
/// Broadcast a message to all connected nodes, namely <see cref="Connections"/>.
/// </summary>
/// <param name="message">The message to be broadcasted.</param>
private void BroadcastMessage(Message message)
private void BroadcastMessage(Message message) => SendToRemoteNodes(message);
eryeer marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Send message to all the RemoteNodes connected to other nodes, faster than ActorSelection.
/// </summary>
private void SendToRemoteNodes(object message)
{
Connections.Tell(message);
foreach (var connection in RemoteNodes.Keys)
shargon marked this conversation as resolved.
Show resolved Hide resolved
{
connection.Tell(message);
}
}

private static IPEndPoint GetIPEndpointFromHostPort(string hostNameOrAddress, int port)
Expand Down Expand Up @@ -189,15 +197,9 @@ private void OnRelay(IInventory inventory)
system.Blockchain.Tell(inventory);
}

private void OnRelayDirectly(IInventory inventory)
{
Connections.Tell(new RemoteNode.Relay { Inventory = inventory });
}
private void OnRelayDirectly(IInventory inventory) => SendToRemoteNodes(new RemoteNode.Relay { Inventory = inventory });

private void OnSendDirectly(IInventory inventory)
{
Connections.Tell(inventory);
}
private void OnSendDirectly(IInventory inventory) => SendToRemoteNodes(inventory);

public static Props Props(NeoSystem system)
{
Expand Down