fixed build errs
netmux got replaced for the most part by swarm.
Juan Batiz-Benet committed
Jul 30, 2014 at 01:13 UTC
b784614c2173090d2740b4613732fce0f090bffd
3 files changed
+7
-153
bitswap/bitswap.go
+7
-11
@@ -1,28 +1,24 @@
1
package bitswap
2
3
import (
4
- "github.com/jbenet/go-ipfs/blocks"
5
- mh "github.com/jbenet/go-multihash"
6
-
7
- "time"
4
+ "time"
5
+ mh "github.com/jbenet/go-multihash"
6
+ blocks "github.com/jbenet/go-ipfs/blocks"
7
+ u "github.com/jbenet/go-ipfs/util"
8
)
9
10
// aliases
11
12
type Ledger struct {
13
Owner mh.Multihash
14
-
14
Partner mh.Multihash
16
-
15
BytesSent uint64
18
-
16
BytesRecv uint64
20
-
17
Timestamp *time.Time
18
}
19
20
type BitSwap struct {
25
- Ledgers map[string]*Ledger
26
- HaveList map[string]*blocks.Block
27
- WantList []*multihash.Multihash
21
+ Ledgers map[u.Key]*Ledger // key is peer.ID
22
+ HaveList map[u.Key]*blocks.Block // key is multihash
23
+ WantList []*mh.Multihash
24
}
netmux/interface.go
deleted
-96
@@ -1,96 +0,0 @@
1
-package netmux
2
-
3
-import (
4
- "net"
5
-)
6
-
7
-// An interface is the module connecting netmux
8
-// to various networks (tcp, udp, webrtc, etc).
9
-// It keeps the relevant connections open.
10
-type Interface struct {
11
-
12
- // Interface network (e.g. udp4, tcp6)
13
- Network string
14
-
15
- // Own network address
16
- Address string
17
- ResolvedAddress *net.UDPAddr
18
-
19
- // Connection
20
- conn net.Conn
21
-
22
- // next packets + close control channels
23
- Input chan *Packet
24
- Output chan *Packet
25
- Closed chan bool
26
- Errors chan error
27
-}
28
-
29
-func NewUDPInterface(network, addr string) (*Interface, error) {
30
- raddr, err := net.ResolveUDPAddr(network, addr)
31
- if err != nil {
32
- return nil, err
33
- }
34
-
35
- conn, err := net.ListenUDP(network, raddr)
36
- if err != nil {
37
- return nil, err
38
- }
39
-
40
- i := &Interface{
41
- Network: network,
42
- Address: addr,
43
- ResolvedAddress: raddr,
44
- conn: conn,
45
- }
46
-
47
- go i.processUDPInput()
48
- go i.processOutput()
49
- return i, nil
50
-}
51
-
52
-func (i *Interface) processOutput() {
53
- for {
54
- select {
55
- case <-i.Closed:
56
- break
57
-
58
- case buffer := <-i.Output:
59
- i.conn.Write([]byte(buffer.Data))
60
- }
61
- }
62
-}
63
-
64
-func (i *Interface) processUDPInput() {
65
- for {
66
- select {
67
- case <-i.Closed:
68
- break
69
-
70
- }
71
- }
72
-}
73
-
74
-func (i *Interface) Read(buffer []byte) bool {
75
- _, err := i.conn.Read(buffer)
76
- if err != nil {
77
- i.Errors <- err
78
- i.Close()
79
- return false
80
- }
81
- return true
82
-}
83
-
84
-func (i *Interface) Close() {
85
- // closing net connection
86
- err := i.conn.Close()
87
- if err != nil {
88
- i.Errors <- err
89
- }
90
-
91
- // closing channels
92
- close(i.Input)
93
- close(i.Output)
94
- close(i.Closed)
95
- close(i.Errors)
96
-}
netmux/netmux.go
deleted
-46
@@ -1,46 +0,0 @@
1
-package netmux
2
-
3
-// The netmux module provides a "network multiplexer".
4
-// The core idea is to have the client be able to connect to
5
-// many different networks (potentially over different transports)
6
-// and multiplex everything over one interface.
7
-
8
-type Netmux struct {
9
- // the list of NetMux interfaces
10
- Interfaces []*Interface
11
-
12
- // The channels to send/recv from
13
- Incoming <-chan *Packet
14
- Outgoing chan<- *Packet
15
-
16
- // internally managed other side of channels
17
- incomingSrc chan<- *Packet
18
- outgoingSrc <-chan *Packet
19
-}
20
-
21
-// Warning: will probably change to adopt multiaddr format
22
-type Packet struct {
23
- // the network addresses to send to
24
- // e.g. tcp4://127.0.0.1:12345
25
- NetAddrTo string
26
-
27
- // the network addresses to recv from
28
- // e.g. tcp4://127.0.0.1:12345
29
- // may be left blank to select one automatically.
30
- NetAddrFrom string
31
-
32
- // the data to send.
33
- Data []byte
34
-}
35
-
36
-func NewNetmux() *Netmux {
37
- n := &Netmux{}
38
-
39
- // setup channels
40
- och := make(chan *Packet)
41
- ich := make(chan *Packet)
42
- n.Incoming, n.incomingSrc = ich, ich
43
- n.Outgoing, n.outgoingSrc = och, och
44
-
45
- return n
46
-}