Commit 68216245 authored by Brian Tiger Chow's avatar Brian Tiger Chow

fix(net) use NetMessage interface

parent 556da76b
...@@ -26,7 +26,7 @@ type Network interface { ...@@ -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 { ...@@ -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() { ...@@ -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() { ...@@ -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) { ...@@ -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
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment