mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 09:59:13 +08:00
fix(net) use NetMessage interface
This commit is contained in:
@ -26,7 +26,7 @@ type Network interface {
|
|||||||
GetProtocols() *mux.ProtocolMap
|
GetProtocols() *mux.ProtocolMap
|
||||||
|
|
||||||
// SendMessage sends given Message out
|
// SendMessage sends given Message out
|
||||||
SendMessage(*msg.Message) error
|
SendMessage(msg.NetMessage) error
|
||||||
|
|
||||||
// Close terminates all network operation
|
// Close terminates all network operation
|
||||||
Close() error
|
Close() error
|
||||||
|
@ -86,7 +86,7 @@ func (n *IpfsNetwork) GetProtocols() *mux.ProtocolMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SendMessage sends given Message out
|
// SendMessage sends given Message out
|
||||||
func (n *IpfsNetwork) SendMessage(m *msg.Message) error {
|
func (n *IpfsNetwork) SendMessage(m msg.NetMessage) error {
|
||||||
n.swarm.Outgoing <- m
|
n.swarm.Outgoing <- m
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -153,7 +153,7 @@ func (s *Swarm) fanOut() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.connsLock.RLock()
|
s.connsLock.RLock()
|
||||||
conn, found := s.conns[msg.Peer.Key()]
|
conn, found := s.conns[msg.Peer().Key()]
|
||||||
s.connsLock.RUnlock()
|
s.connsLock.RUnlock()
|
||||||
|
|
||||||
if !found {
|
if !found {
|
||||||
@ -164,7 +164,7 @@ func (s *Swarm) fanOut() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// queue it in the connection's buffer
|
// queue it in the connection's buffer
|
||||||
conn.Outgoing.MsgChan <- msg.Data
|
conn.Outgoing.MsgChan <- msg.Data()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,7 +189,7 @@ func (s *Swarm) fanIn(c *conn.Conn) {
|
|||||||
goto out
|
goto out
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := &msg.Message{Peer: c.Peer, Data: data}
|
msg := msg.New(c.Peer, data)
|
||||||
s.Incoming <- msg
|
s.Incoming <- msg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user