starting to integrate new net
Juan Batiz-Benet committed
Sep 14, 2014 at 04:52 UTC
c14123397aecfa7149cedeed31e0654304421685
4 files changed
+18
-16
bitswap/message.go
+1
-1
@@ -2,8 +2,8 @@ package bitswap
2
3
import (
4
blocks "github.com/jbenet/go-ipfs/blocks"
5
+ swarm "github.com/jbenet/go-ipfs/net/swarm"
6
peer "github.com/jbenet/go-ipfs/peer"
6
- swarm "github.com/jbenet/go-ipfs/swarm"
7
u "github.com/jbenet/go-ipfs/util"
8
)
9
core/core.go
+12
-6
@@ -5,15 +5,18 @@ import (
5
"errors"
6
"fmt"
7
8
+ context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
9
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
10
b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
11
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
11
- "github.com/jbenet/go-ipfs/bitswap"
12
+
13
+ bitswap "github.com/jbenet/go-ipfs/bitswap"
14
bserv "github.com/jbenet/go-ipfs/blockservice"
15
config "github.com/jbenet/go-ipfs/config"
16
ci "github.com/jbenet/go-ipfs/crypto"
17
merkledag "github.com/jbenet/go-ipfs/merkledag"
16
- swarm "github.com/jbenet/go-ipfs/net/swarm"
18
+ inet "github.com/jbenet/go-ipfs/net"
19
+ mux "github.com/jbenet/go-ipfs/net/mux"
20
path "github.com/jbenet/go-ipfs/path"
21
peer "github.com/jbenet/go-ipfs/peer"
22
routing "github.com/jbenet/go-ipfs/routing"
@@ -37,7 +40,7 @@ type IpfsNode struct {
40
Datastore ds.Datastore
41
42
// the network message stream
40
- Swarm *swarm.Swarm
43
+ Network inet.Network
44
45
// the routing system. recommend ipfs-dht
46
Routing routing.IpfsRouting
@@ -75,15 +78,18 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
78
}
79
80
var (
78
- net *swarm.Swarm
81
+ net *inet.Network
82
// TODO: refactor so we can use IpfsRouting interface instead of being DHT-specific
83
route *dht.IpfsDHT
84
swap *bitswap.BitSwap
85
)
86
87
if online {
85
- net = swarm.NewSwarm(local)
86
- err = net.Listen()
88
+ // add protocol services here.
89
+ net, err := inet.NewIpfsNetwork(context.TODO(), local, &mux.ProtocolMap{
90
+ // "1": dhtService,
91
+ // "2": bitswapService,
92
+ })
93
if err != nil {
94
return nil, err
95
}
routing/dht/dht.go
+2
-6
@@ -7,7 +7,7 @@ import (
7
"sync"
8
"time"
9
10
- swarm "github.com/jbenet/go-ipfs/net/swarm"
10
+ inet "github.com/jbenet/go-ipfs/net"
11
peer "github.com/jbenet/go-ipfs/peer"
12
kb "github.com/jbenet/go-ipfs/routing/kbucket"
13
u "github.com/jbenet/go-ipfs/util"
@@ -28,8 +28,7 @@ type IpfsDHT struct {
28
// NOTE: (currently, only a single table is used)
29
routingTables []*kb.RoutingTable
30
31
- network swarm.Network
32
- netChan *swarm.Chan
31
+ network inet.Network
32
33
// Local peer (yourself)
34
self *peer.Peer
@@ -48,9 +47,6 @@ type IpfsDHT struct {
47
48
//lock to make diagnostics work better
49
diaglock sync.Mutex
51
-
52
- // listener is a server to register to listen for responses to messages
53
- listener *swarm.MessageListener
50
}
51
52
// NewDHT creates a new DHT object with the given peer as the 'local' host
routing/dht/dht_test.go
+3
-3
@@ -6,7 +6,7 @@ import (
6
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
7
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
8
ci "github.com/jbenet/go-ipfs/crypto"
9
- identify "github.com/jbenet/go-ipfs/identify"
9
+ spipe "github.com/jbenet/go-ipfs/crypto/spipe"
10
swarm "github.com/jbenet/go-ipfs/net/swarm"
11
peer "github.com/jbenet/go-ipfs/peer"
12
u "github.com/jbenet/go-ipfs/util"
@@ -36,7 +36,7 @@ func setupDHTS(n int, t *testing.T) ([]*ma.Multiaddr, []*peer.Peer, []*IpfsDHT)
36
}
37
p.PubKey = pk
38
p.PrivKey = sk
39
- id, err := identify.IDFromPubKey(pk)
39
+ id, err := spipe.IDFromPubKey(pk)
40
if err != nil {
41
panic(err)
42
}
@@ -68,7 +68,7 @@ func makePeer(addr *ma.Multiaddr) *peer.Peer {
68
}
69
p.PrivKey = sk
70
p.PubKey = pk
71
- id, err := identify.IDFromPubKey(pk)
71
+ id, err := spipe.IDFromPubKey(pk)
72
if err != nil {
73
panic(err)
74
}