1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-09-09 19:32:24 +08:00

wip with DHT

@whyrusleeping @jbenet this is a WIP with the DHT.

wip

License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>

Conflicts:
	epictest/addcat_test.go
	exchange/bitswap/testnet/peernet.go
	exchange/bitswap/testutils.go
	routing/mock/centralized_server.go
	routing/mock/centralized_test.go
	routing/mock/interface.go

fix(routing/mock) fill in function definition
This commit is contained in:
Brian Tiger Chow
2014-12-17 10:02:19 -08:00
parent 14990bb556
commit ca32a83394
15 changed files with 127 additions and 68 deletions

View File

@ -1,14 +1,12 @@
package bitswap
import (
"math"
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/go-datastore"
bsnet "github.com/jbenet/go-ipfs/exchange/bitswap/network"
mockpeernet "github.com/jbenet/go-ipfs/net/mock"
peer "github.com/jbenet/go-ipfs/peer"
mockrouting "github.com/jbenet/go-ipfs/routing/mock"
delay "github.com/jbenet/go-ipfs/util/delay"
testutil "github.com/jbenet/go-ipfs/util/testutil"
)
@ -17,16 +15,7 @@ type peernet struct {
routingserver mockrouting.Server
}
func StreamNetWithDelay(
ctx context.Context,
rs mockrouting.Server,
d delay.D) (Network, error) {
net := mockpeernet.New(ctx)
net.SetLinkDefaults(mockpeernet.LinkOptions{
Latency: d.Get(),
Bandwidth: math.MaxInt32, // TODO inject
})
func StreamNet(ctx context.Context, net mockpeernet.Mocknet, rs mockrouting.Server) (Network, error) {
return &peernet{net, rs}, nil
}
@ -39,7 +28,7 @@ func (pn *peernet) Adapter(p testutil.Peer) bsnet.BitSwapNetwork {
for _, other := range peers {
pn.Mocknet.LinkPeers(p.ID(), other)
}
routing := pn.routingserver.Client(peer.PeerInfo{ID: p.ID()})
routing := pn.routingserver.ClientWithDatastore(context.TODO(), p, ds.NewMapDatastore())
return bsnet.NewFromIpfsNetwork(client, routing)
}