@cryptotaxi247 / kubo / commits / 19eb35137

refactor(routing) rename grandcentral to supernode

thanks @mappum remove .go-ipfs

Brian Tiger Chow committed Feb 4, 2015 at 04:07 UTC 19eb35137b90d0f626d0148193df72190812deab
7 files changed +37 -37
cmd/routingd/main.go
+2 -2
@@ -12,7 +12,7 @@ import (
12 syncds "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/sync"
13 core "github.com/jbenet/go-ipfs/core"
14 corehttp "github.com/jbenet/go-ipfs/core/corehttp"
15 - "github.com/jbenet/go-ipfs/core/corerouting"
15 + corerouting "github.com/jbenet/go-ipfs/core/corerouting"
16 config "github.com/jbenet/go-ipfs/repo/config"
17 fsrepo "github.com/jbenet/go-ipfs/repo/fsrepo"
18 s3datastore "github.com/jbenet/go-ipfs/thirdparty/s3-datastore"
@@ -68,7 +68,7 @@ func run() error {
68 node, err := core.NewIPFSNode(ctx,
69 core.OnlineWithOptions(
70 repo,
71 - corerouting.GrandCentralServer(enhanced),
71 + corerouting.SupernodeServer(enhanced),
72 core.DefaultHostOption),
73 )
74 if err != nil {
core/corerouting/core.go
+14 -14
@@ -8,8 +8,8 @@ import (
8 core "github.com/jbenet/go-ipfs/core"
9 "github.com/jbenet/go-ipfs/p2p/peer"
10 routing "github.com/jbenet/go-ipfs/routing"
11 - grandcentral "github.com/jbenet/go-ipfs/routing/grandcentral"
12 - gcproxy "github.com/jbenet/go-ipfs/routing/grandcentral/proxy"
11 + supernode "github.com/jbenet/go-ipfs/routing/supernode"
12 + gcproxy "github.com/jbenet/go-ipfs/routing/supernode/proxy"
13 )
14
15 // NB: DHT option is included in the core to avoid 1) because it's a sane
@@ -17,16 +17,16 @@ import (
17 // the core if it's going to be the default)
18
19 var (
20 - errHostMissing = errors.New("grandcentral client requires a Host component")
21 - errIdentityMissing = errors.New("grandcentral server requires a peer ID identity")
22 - errPeerstoreMissing = errors.New("grandcentral server requires a peerstore")
23 - errServersMissing = errors.New("grandcentral client requires at least 1 server peer")
20 + errHostMissing = errors.New("supernode routing client requires a Host component")
21 + errIdentityMissing = errors.New("supernode routing server requires a peer ID identity")
22 + errPeerstoreMissing = errors.New("supernode routing server requires a peerstore")
23 + errServersMissing = errors.New("supernode routing client requires at least 1 server peer")
24 )
25
26 -// GrandCentralServer returns a configuration for a routing server that stores
26 +// SupernodeServer returns a configuration for a routing server that stores
27 // routing records to the provided datastore. Only routing records are store in
28 // the datastore.
29 -func GrandCentralServer(recordSource datastore.ThreadSafeDatastore) core.RoutingOption {
29 +func SupernodeServer(recordSource datastore.ThreadSafeDatastore) core.RoutingOption {
30 return func(ctx context.Context, node *core.IpfsNode) (routing.IpfsRouting, error) {
31 if node.Peerstore == nil {
32 return nil, errPeerstoreMissing
@@ -37,7 +37,7 @@ func GrandCentralServer(recordSource datastore.ThreadSafeDatastore) core.Routing
37 if node.Identity == "" {
38 return nil, errIdentityMissing
39 }
40 - server, err := grandcentral.NewServer(recordSource, node.Peerstore, node.Identity)
40 + server, err := supernode.NewServer(recordSource, node.Peerstore, node.Identity)
41 if err != nil {
42 return nil, err
43 }
@@ -45,13 +45,13 @@ func GrandCentralServer(recordSource datastore.ThreadSafeDatastore) core.Routing
45 Handler: server,
46 Local: node.Identity,
47 }
48 - node.PeerHost.SetStreamHandler(gcproxy.ProtocolGCR, proxy.HandleStream)
49 - return grandcentral.NewClient(proxy, node.PeerHost, node.Peerstore, node.Identity)
48 + node.PeerHost.SetStreamHandler(gcproxy.ProtocolSNR, proxy.HandleStream)
49 + return supernode.NewClient(proxy, node.PeerHost, node.Peerstore, node.Identity)
50 }
51 }
52
53 // TODO doc
54 -func GrandCentralClient(remotes ...peer.PeerInfo) core.RoutingOption {
54 +func SupernodeClient(remotes ...peer.PeerInfo) core.RoutingOption {
55 return func(ctx context.Context, node *core.IpfsNode) (routing.IpfsRouting, error) {
56 if len(remotes) < 1 {
57 return nil, errServersMissing
@@ -78,7 +78,7 @@ func GrandCentralClient(remotes ...peer.PeerInfo) core.RoutingOption {
78 ids = append(ids, info.ID)
79 }
80 proxy := gcproxy.Standard(node.PeerHost, ids)
81 - node.PeerHost.SetStreamHandler(gcproxy.ProtocolGCR, proxy.HandleStream)
82 - return grandcentral.NewClient(proxy, node.PeerHost, node.Peerstore, node.Identity)
81 + node.PeerHost.SetStreamHandler(gcproxy.ProtocolSNR, proxy.HandleStream)
82 + return supernode.NewClient(proxy, node.PeerHost, node.Peerstore, node.Identity)
83 }
84 }
routing/supernode/client.go renamed
+4 -4
@@ -1,4 +1,4 @@
1 -package grandcentral
1 +package supernode
2
3 import (
4 "bytes"
@@ -10,13 +10,13 @@ import (
10 peer "github.com/jbenet/go-ipfs/p2p/peer"
11 routing "github.com/jbenet/go-ipfs/routing"
12 pb "github.com/jbenet/go-ipfs/routing/dht/pb"
13 - proxy "github.com/jbenet/go-ipfs/routing/grandcentral/proxy"
13 + proxy "github.com/jbenet/go-ipfs/routing/supernode/proxy"
14 eventlog "github.com/jbenet/go-ipfs/thirdparty/eventlog"
15 u "github.com/jbenet/go-ipfs/util"
16 errors "github.com/jbenet/go-ipfs/util/debugerror"
17 )
18
19 -var log = eventlog.Logger("grandcentral")
19 +var log = eventlog.Logger("supernode")
20
21 type Client struct {
22 peerhost host.Host
@@ -128,7 +128,7 @@ func makeRecord(ps peer.Peerstore, p peer.ID, k u.Key, v []byte) (*pb.Record, er
128
129 func (c *Client) Ping(ctx context.Context, id peer.ID) (time.Duration, error) {
130 defer log.EventBegin(ctx, "ping", id).Done()
131 - return time.Nanosecond, errors.New("grandcentral routing does not support the ping method")
131 + return time.Nanosecond, errors.New("supernode routing does not support the ping method")
132 }
133
134 var _ routing.IpfsRouting = &Client{}
routing/supernode/proxy/loopback.go renamed
routing/supernode/proxy/standard.go renamed
+5 -5
@@ -13,9 +13,9 @@ import (
13 errors "github.com/jbenet/go-ipfs/util/debugerror"
14 )
15
16 -const ProtocolGCR = "/ipfs/grandcentral"
16 +const ProtocolSNR = "/ipfs/supernoderouting"
17
18 -var log = eventlog.Logger("grandcentral/proxy")
18 +var log = eventlog.Logger("supernode/proxy")
19
20 type Proxy interface {
21 HandleStream(inet.Stream)
@@ -34,7 +34,7 @@ func Standard(h host.Host, remotes []peer.ID) Proxy {
34
35 func (p *standard) HandleStream(s inet.Stream) {
36 // TODO(brian): Should clients be able to satisfy requests?
37 - log.Error("grandcentral client received (dropped) a routing message from", s.Conn().RemotePeer())
37 + log.Error("supernode client received (dropped) a routing message from", s.Conn().RemotePeer())
38 s.Close()
39 }
40
@@ -64,7 +64,7 @@ func (px *standard) sendMessage(ctx context.Context, m *dhtpb.Message, remote pe
64 if err = px.Host.Connect(ctx, peer.PeerInfo{ID: remote}); err != nil {
65 return err
66 }
67 - s, err := px.Host.NewStream(ProtocolGCR, remote)
67 + s, err := px.Host.NewStream(ProtocolSNR, remote)
68 if err != nil {
69 return err
70 }
@@ -100,7 +100,7 @@ func (px *standard) sendRequest(ctx context.Context, m *dhtpb.Message, remote pe
100 e.SetError(err)
101 return nil, err
102 }
103 - s, err := px.Host.NewStream(ProtocolGCR, remote)
103 + s, err := px.Host.NewStream(ProtocolSNR, remote)
104 if err != nil {
105 e.SetError(err)
106 return nil, err
routing/supernode/server.go renamed
+3 -3
@@ -1,4 +1,4 @@
1 -package grandcentral
1 +package supernode
2
3 import (
4 "fmt"
@@ -8,7 +8,7 @@ import (
8 datastore "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
9 peer "github.com/jbenet/go-ipfs/p2p/peer"
10 dhtpb "github.com/jbenet/go-ipfs/routing/dht/pb"
11 - proxy "github.com/jbenet/go-ipfs/routing/grandcentral/proxy"
11 + proxy "github.com/jbenet/go-ipfs/routing/supernode/proxy"
12 util "github.com/jbenet/go-ipfs/util"
13 errors "github.com/jbenet/go-ipfs/util/debugerror"
14 )
@@ -21,7 +21,7 @@ type Server struct {
21 *proxy.Loopback // so server can be injected into client
22 }
23
24 -// NewServer creates a new GrandCentral routing Server
24 +// NewServer creates a new Supernode routing Server
25 func NewServer(ds datastore.ThreadSafeDatastore, ps peer.Peerstore, local peer.ID) (*Server, error) {
26 s := &Server{local, ds, ps, nil}
27 s.Loopback = &proxy.Loopback{
test/integration/grandcentral_test.go
+9 -9
@@ -21,9 +21,9 @@ import (
21 testutil "github.com/jbenet/go-ipfs/util/testutil"
22 )
23
24 -func TestGrandcentralBootstrappedAddCat(t *testing.T) {
25 - // create 8 grandcentral bootstrap nodes
26 - // create 2 grandcentral clients both bootstrapped to the bootstrap nodes
24 +func TestSupernodeBootstrappedAddCat(t *testing.T) {
25 + // create 8 supernode-routing bootstrap nodes
26 + // create 2 supernode-routing clients both bootstrapped to the bootstrap nodes
27 // let the bootstrap nodes share a single datastore
28 // add a large file on one node then cat the file from the other
29 conf := testutil.LatencyConfig{
@@ -31,16 +31,16 @@ func TestGrandcentralBootstrappedAddCat(t *testing.T) {
31 RoutingLatency: 0,
32 BlockstoreLatency: 0,
33 }
34 - if err := RunGrandcentralBootstrappedAddCat(RandomBytes(100*unit.MB), conf); err != nil {
34 + if err := RunSupernodeBootstrappedAddCat(RandomBytes(100*unit.MB), conf); err != nil {
35 t.Fatal(err)
36 }
37 }
38
39 -func RunGrandcentralBootstrappedAddCat(data []byte, conf testutil.LatencyConfig) error {
39 +func RunSupernodeBootstrappedAddCat(data []byte, conf testutil.LatencyConfig) error {
40 ctx, cancel := context.WithCancel(context.Background())
41 defer cancel()
42
43 - servers, clients, err := InitializeGrandCentralNetwork(ctx, 8, 2, conf)
43 + servers, clients, err := InitializeSupernodeNetwork(ctx, 8, 2, conf)
44 if err != nil {
45 return err
46 }
@@ -73,7 +73,7 @@ func RunGrandcentralBootstrappedAddCat(data []byte, conf testutil.LatencyConfig)
73 return nil
74 }
75
76 -func InitializeGrandCentralNetwork(
76 +func InitializeSupernodeNetwork(
77 ctx context.Context,
78 numServers, numClients int,
79 conf testutil.LatencyConfig) ([]*core.IpfsNode, []*core.IpfsNode, error) {
@@ -100,7 +100,7 @@ func InitializeGrandCentralNetwork(
100 for i := range iter.N(numServers) {
101 p := serverPeers[i]
102 bootstrap, err := core.NewIPFSNode(ctx, MocknetTestRepo(p, mn.Host(p), conf,
103 - corerouting.GrandCentralServer(routingDatastore)))
103 + corerouting.SupernodeServer(routingDatastore)))
104 if err != nil {
105 return nil, nil, err
106 }
@@ -117,7 +117,7 @@ func InitializeGrandCentralNetwork(
117 for i := range iter.N(numClients) {
118 p := clientPeers[i]
119 n, err := core.NewIPFSNode(ctx, MocknetTestRepo(p, mn.Host(p), conf,
120 - corerouting.GrandCentralClient(bootstrapInfos...)))
120 + corerouting.SupernodeClient(bootstrapInfos...)))
121 if err != nil {
122 return nil, nil, err
123 }