From 7d6a58308b977273ab03ad0e0235cddf9e0fcb58 Mon Sep 17 00:00:00 2001 From: Carlos Cobo Date: Thu, 24 Jul 2014 14:30:23 +0200 Subject: [PATCH] Fix #1 build errors. --- bitswap/bitswap.go | 7 ++++--- netmux/interface.go | 28 ++++++++++++++-------------- netmux/netmux.go | 11 +++-------- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/bitswap/bitswap.go b/bitswap/bitswap.go index 44e0c393cc2..c5875092023 100644 --- a/bitswap/bitswap.go +++ b/bitswap/bitswap.go @@ -1,7 +1,8 @@ package bitswap import ( - peer "github.com/jbenet/go-ipfs/peer" + "github.com/jbenet/go-ipfs/blocks" + "github.com/jbenet/go-multihash" ) // aliases @@ -11,7 +12,7 @@ type Ledger struct { } type BitSwap struct { - Ledgers map[peer.ID]*Ledger - HaveList map[multihash.Multihash]*block.Block + Ledgers map[string]*Ledger + HaveList map[string]*blocks.Block WantList []*multihash.Multihash } diff --git a/netmux/interface.go b/netmux/interface.go index 68819a930d4..af49c6d0cad 100644 --- a/netmux/interface.go +++ b/netmux/interface.go @@ -13,38 +13,38 @@ type Interface struct { Network string // Own network address - Address string - ResolvedAddress string + Address string + ResolvedAddress *net.UDPAddr // Connection - conn *net.Conn + conn net.Conn // next packets + close control channels - Input chan *Packet + Input chan *Packet Output chan *Packet Closed chan bool Errors chan error } -func NewUDPInterface(net, addr string) (*Interface, error) { - raddr, err := net.ResolveUDPAddr(net, addr) +func NewUDPInterface(network, addr string) (*Interface, error) { + raddr, err := net.ResolveUDPAddr(network, addr) if err != nil { return nil, err } - conn, err := net.ListenUDP(net, addr) + conn, err := net.ListenUDP(network, raddr) if err != nil { return nil, err } i := &Interface{ - Network: net, + Network: network, Address: addr, ResolvedAddress: raddr, conn: conn, } - go i.processInput() + go i.processUDPInput() go i.processOutput() return i, nil } @@ -53,10 +53,10 @@ func (i *Interface) processOutput() { for { select { case <-i.Closed: - break; + break case buffer := <-i.Output: - i.conn.Write([]byte(buffer)) + i.conn.Write([]byte(buffer.Data)) } } } @@ -64,15 +64,15 @@ func (i *Interface) processOutput() { func (i *Interface) processUDPInput() { for { select { - case <- i.Closed: - break; + case <-i.Closed: + break } } } func (i *Interface) Read(buffer []byte) bool { - n, err := i.Conn.Read(buffer) + _, err := i.conn.Read(buffer) if err != nil { i.Errors <- err i.Close() diff --git a/netmux/netmux.go b/netmux/netmux.go index eb71e21909a..3ef3654b69f 100644 --- a/netmux/netmux.go +++ b/netmux/netmux.go @@ -1,9 +1,5 @@ package netmux -import ( - "net" -) - // The netmux module provides a "network multiplexer". // The core idea is to have the client be able to connect to // many different networks (potentially over different transports) @@ -22,9 +18,8 @@ type Netmux struct { outgoingSrc <-chan *Packet } - // Warning: will probably change to adopt multiaddr format -type Packet { +type Packet struct { // the network addresses to send to // e.g. tcp4://127.0.0.1:12345 NetAddrTo string @@ -44,8 +39,8 @@ func NewNetmux() *Netmux { // setup channels och := make(chan *Packet) ich := make(chan *Packet) - n.Incoming, n.incomingSrc := ich, ich - n.Outgoing, n.outgoingSrc := och, och + n.Incoming, n.incomingSrc = ich, ich + n.Outgoing, n.outgoingSrc = och, och return n }