diff --git a/pkg/network/server.go b/pkg/network/server.go index b0b3eef89..5ab280f19 100644 --- a/pkg/network/server.go +++ b/pkg/network/server.go @@ -676,12 +676,14 @@ func (s *Server) requestTx(hashes ...util.Uint256) { } func (s *Server) relayInventory(t payload.InventoryType, hashes ...util.Uint256) { + payload := payload.NewInventory(t, hashes) + msg := NewMessage(s.Net, CMDInv, payload) + for peer := range s.Peers() { - if !peer.Handshaked() { + if !peer.Handshaked() || !peer.Version().Relay { continue } - payload := payload.NewInventory(t, hashes) - s.RelayDirectly(peer, payload) + peer.WriteMsg(msg) } } @@ -713,14 +715,3 @@ func (s *Server) RelayTxn(t *transaction.Transaction) RelayReason { return RelaySucceed } - -// RelayDirectly relays directly the inventory to the remote peers. -// Reference: the method OnRelayDirectly in C#: https://github.com/neo-project/neo/blob/master/neo/Network/P2P/LocalNode.cs#L166 -func (s *Server) RelayDirectly(p Peer, inv *payload.Inventory) { - if !p.Version().Relay { - return - } - - p.WriteMsg(NewMessage(s.Net, CMDInv, inv)) - -}