@cryptotaxi247 / kubo / commits / 68216245c

fix(net) use NetMessage interface

Brian Tiger Chow committed Sep 14, 2014 at 05:24 UTC 68216245c685d65c5192f611d5b71f1743f90c22
3 files changed +5 -5
net/interface.go
+1 -1
@@ -26,7 +26,7 @@ type Network interface {
26 GetProtocols() *mux.ProtocolMap
27
28 // SendMessage sends given Message out
29 - SendMessage(*msg.Message) error
29 + SendMessage(msg.NetMessage) error
30
31 // Close terminates all network operation
32 Close() error
net/net.go
+1 -1
@@ -86,7 +86,7 @@ func (n *IpfsNetwork) GetProtocols() *mux.ProtocolMap {
86 }
87
88 // SendMessage sends given Message out
89 -func (n *IpfsNetwork) SendMessage(m *msg.Message) error {
89 +func (n *IpfsNetwork) SendMessage(m msg.NetMessage) error {
90 n.swarm.Outgoing <- m
91 return nil
92 }
net/swarm/conn.go
+3 -3
@@ -153,7 +153,7 @@ func (s *Swarm) fanOut() {
153 }
154
155 s.connsLock.RLock()
156 - conn, found := s.conns[msg.Peer.Key()]
156 + conn, found := s.conns[msg.Peer().Key()]
157 s.connsLock.RUnlock()
158
159 if !found {
@@ -164,7 +164,7 @@ func (s *Swarm) fanOut() {
164 }
165
166 // queue it in the connection's buffer
167 - conn.Outgoing.MsgChan <- msg.Data
167 + conn.Outgoing.MsgChan <- msg.Data()
168 }
169 }
170 }
@@ -189,7 +189,7 @@ func (s *Swarm) fanIn(c *conn.Conn) {
189 goto out
190 }
191
192 - msg := &msg.Message{Peer: c.Peer, Data: data}
192 + msg := msg.New(c.Peer, data)
193 s.Incoming <- msg
194 }
195 }