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

Drop Addr messages if we didn't send GetAddr #2097

Merged
merged 1 commit into from
Nov 25, 2020
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
3 changes: 3 additions & 0 deletions src/neo/Network/P2P/RemoteNode.ProtocolHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,9 @@ private void OnMessage(Message msg)

private void OnAddrMessageReceived(AddrPayload payload)
{
ref bool sent = ref sentCommands[(byte)MessageCommand.GetAddr];
if (!sent) return;
sent = false;
system.LocalNode.Tell(new Peer.Peers
{
EndPoints = payload.AddressList.Select(p => p.EndPoint).Where(p => p.Port > 0)
Expand Down
2 changes: 2 additions & 0 deletions src/neo/Network/P2P/RemoteNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal class Relay { public IInventory Inventory; }
private readonly NeoSystem system;
private readonly Queue<Message> message_queue_high = new Queue<Message>();
private readonly Queue<Message> message_queue_low = new Queue<Message>();
private readonly bool[] sentCommands = new bool[1 << sizeof(MessageCommand)];
private ByteString msg_buffer = ByteString.Empty;
private bool ack = true;

Expand Down Expand Up @@ -197,6 +198,7 @@ private void SendMessage(Message message)
{
ack = false;
SendData(ByteString.FromBytes(message.ToArray()));
sentCommands[(byte)message.Command] = true;
}

private Message TryParseMessage()
Expand Down