提交 c1412339 作者: Juan Batiz-Benet 提交者: Brian Tiger Chow

starting to integrate new net

上级 f71be6e9
......@@ -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"
)
......
......@@ -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"
......@@ -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
......@@ -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
}
......
......@@ -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"
......@@ -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
......@@ -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
......
......@@ -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"
......@@ -36,7 +36,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)
}
......@@ -68,7 +68,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)
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论