diff --git a/src/neo/Network/P2P/LocalNode.cs b/src/neo/Network/P2P/LocalNode.cs
index ffd0ac9930..bdc4713bfe 100644
--- a/src/neo/Network/P2P/LocalNode.cs
+++ b/src/neo/Network/P2P/LocalNode.cs
@@ -155,7 +155,7 @@ protected override void NeedMorePeers(int count)
else
{
// Will call AddPeers with default SeedList set cached on .
- // It will try to add those, sequentially, to the list of currently uncconected ones.
+ // It will try to add those, sequentially, to the list of currently unconnected ones.
Random rand = new Random();
AddPeers(SeedList.Where(u => u != null).OrderBy(p => rand.Next()).Take(count));
@@ -197,7 +197,22 @@ private void OnRelay(IInventory inventory)
system.Blockchain.Tell(inventory);
}
- private void OnRelayDirectly(IInventory inventory) => SendToRemoteNodes(new RemoteNode.Relay { Inventory = inventory });
+ private void OnRelayDirectly(IInventory inventory)
+ {
+ var message = new RemoteNode.Relay { Inventory = inventory };
+ // When relaying a block, if the block's index is greater than 'LastBlockIndex' of the RemoteNode, relay the block;
+ // otherwise, don't relay.
+ if (inventory is Block block)
+ {
+ foreach (KeyValuePair kvp in RemoteNodes)
+ {
+ if (block.Index > kvp.Value.LastBlockIndex)
+ kvp.Key.Tell(message);
+ }
+ }
+ else
+ SendToRemoteNodes(message);
+ }
private void OnSendDirectly(IInventory inventory) => SendToRemoteNodes(inventory);