Skip to content

Commit

Permalink
starting to integrate new net
Browse files Browse the repository at this point in the history
  • Loading branch information
jbenet committed Sep 14, 2014
1 parent 42d86b5 commit 7223700
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
2 changes: 1 addition & 1 deletion bitswap/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package bitswap

import (
blocks "github.com/jbenet/go-ipfs/blocks"
swarm "github.com/jbenet/go-ipfs/net/swarm"
peer "github.com/jbenet/go-ipfs/peer"
swarm "github.com/jbenet/go-ipfs/swarm"
u "github.com/jbenet/go-ipfs/util"
)

Expand Down
18 changes: 12 additions & 6 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@ import (
"errors"
"fmt"

context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
"github.com/jbenet/go-ipfs/bitswap"

bitswap "github.com/jbenet/go-ipfs/bitswap"
bserv "github.com/jbenet/go-ipfs/blockservice"
config "github.com/jbenet/go-ipfs/config"
ci "github.com/jbenet/go-ipfs/crypto"
merkledag "github.com/jbenet/go-ipfs/merkledag"
swarm "github.com/jbenet/go-ipfs/net/swarm"
inet "github.com/jbenet/go-ipfs/net"
mux "github.com/jbenet/go-ipfs/net/mux"
path "github.com/jbenet/go-ipfs/path"
peer "github.com/jbenet/go-ipfs/peer"
routing "github.com/jbenet/go-ipfs/routing"
Expand All @@ -37,7 +40,7 @@ type IpfsNode struct {
Datastore ds.Datastore

// the network message stream
Swarm *swarm.Swarm
Network inet.Network

// the routing system. recommend ipfs-dht
Routing routing.IpfsRouting
Expand Down Expand Up @@ -75,15 +78,18 @@ func NewIpfsNode(cfg *config.Config, online bool) (*IpfsNode, error) {
}

var (
net *swarm.Swarm
net *inet.Network
// TODO: refactor so we can use IpfsRouting interface instead of being DHT-specific
route *dht.IpfsDHT
swap *bitswap.BitSwap
)

if online {
net = swarm.NewSwarm(local)
err = net.Listen()
// add protocol services here.
net, err := inet.NewIpfsNetwork(context.TODO(), local, &mux.ProtocolMap{
// "1": dhtService,
// "2": bitswapService,
})
if err != nil {
return nil, err
}
Expand Down
8 changes: 2 additions & 6 deletions routing/dht/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

swarm "github.com/jbenet/go-ipfs/net/swarm"
inet "github.com/jbenet/go-ipfs/net"
peer "github.com/jbenet/go-ipfs/peer"
kb "github.com/jbenet/go-ipfs/routing/kbucket"
u "github.com/jbenet/go-ipfs/util"
Expand All @@ -28,8 +28,7 @@ type IpfsDHT struct {
// NOTE: (currently, only a single table is used)
routingTables []*kb.RoutingTable

network swarm.Network
netChan *swarm.Chan
network inet.Network

// Local peer (yourself)
self *peer.Peer
Expand All @@ -48,9 +47,6 @@ type IpfsDHT struct {

//lock to make diagnostics work better
diaglock sync.Mutex

// listener is a server to register to listen for responses to messages
listener *swarm.MessageListener
}

// NewDHT creates a new DHT object with the given peer as the 'local' host
Expand Down
6 changes: 3 additions & 3 deletions routing/dht/dht_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
ds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/datastore.go"
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
ci "github.com/jbenet/go-ipfs/crypto"
identify "github.com/jbenet/go-ipfs/identify"
spipe "github.com/jbenet/go-ipfs/crypto/spipe"
swarm "github.com/jbenet/go-ipfs/net/swarm"
peer "github.com/jbenet/go-ipfs/peer"
u "github.com/jbenet/go-ipfs/util"
Expand Down Expand Up @@ -35,7 +35,7 @@ func setupDHTS(n int, t *testing.T) ([]*ma.Multiaddr, []*peer.Peer, []*IpfsDHT)
}
p.PubKey = pk
p.PrivKey = sk
id, err := identify.IDFromPubKey(pk)
id, err := spipe.IDFromPubKey(pk)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -67,7 +67,7 @@ func makePeer(addr *ma.Multiaddr) *peer.Peer {
}
p.PrivKey = sk
p.PubKey = pk
id, err := identify.IDFromPubKey(pk)
id, err := spipe.IDFromPubKey(pk)
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 7223700

Please sign in to comment.