@cryptotaxi247 / kubo / commits / efa282d46

update for pubsub rename

License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Oct 24, 2018 at 09:37 UTC efa282d46e97c2609c2f9713cd98adc5af425f07
5 files changed +31 -31
README.md
+1 -1
@@ -389,7 +389,7 @@ Some places to get you started on the codebase:
389 - libp2p
390 - libp2p: https://github.com/libp2p/go-libp2p
391 - DHT: https://github.com/libp2p/go-libp2p-kad-dht
392 - - PubSub: https://github.com/libp2p/go-floodsub
392 + - PubSub: https://github.com/libp2p/go-libp2p-pubsub
393
394 ### CLI, HTTP-API, Architecture Diagram
395
cmd/ipfs/daemon.go
+3 -3
@@ -50,7 +50,7 @@ const (
50 unencryptTransportKwd = "disable-transport-encryption"
51 unrestrictedApiAccessKwd = "unrestricted-api"
52 writableKwd = "writable"
53 - enableFloodSubKwd = "enable-pubsub-experiment"
53 + enablePubSubKwd = "enable-pubsub-experiment"
54 enableIPNSPubSubKwd = "enable-namesys-pubsub"
55 enableMultiplexKwd = "enable-mplex-experiment"
56 // apiAddrKwd = "address-api"
@@ -163,7 +163,7 @@ Headers.
163 cmdkit.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed").WithDefault(true),
164 cmdkit.BoolOption(offlineKwd, "Run offline. Do not connect to the rest of the network but provide local API."),
165 cmdkit.BoolOption(migrateKwd, "If true, assume yes at the migrate prompt. If false, assume no."),
166 - cmdkit.BoolOption(enableFloodSubKwd, "Instantiate the ipfs daemon with the experimental pubsub feature enabled."),
166 + cmdkit.BoolOption(enablePubSubKwd, "Instantiate the ipfs daemon with the experimental pubsub feature enabled."),
167 cmdkit.BoolOption(enableIPNSPubSubKwd, "Enable IPNS record distribution through pubsub; enables pubsub."),
168 cmdkit.BoolOption(enableMultiplexKwd, "Add the experimental 'go-multiplex' stream muxer to libp2p on construction.").WithDefault(true),
169
@@ -285,7 +285,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
285
286 offline, _ := req.Options[offlineKwd].(bool)
287 ipnsps, _ := req.Options[enableIPNSPubSubKwd].(bool)
288 - pubsub, _ := req.Options[enableFloodSubKwd].(bool)
288 + pubsub, _ := req.Options[enablePubSubKwd].(bool)
289 mplex, _ := req.Options[enableMultiplexKwd].(bool)
290
291 // Start assembling node config
core/core.go
+11 -11
@@ -44,6 +44,7 @@ import (
44 ic "gx/ipfs/QmPvyPwuCgJ7pDmrKDxRtsScJgBaM5h4EpRL2qQJsmXf4n/go-libp2p-crypto"
45 nilrouting "gx/ipfs/QmQ9PR61a8rwEFuFNs7JMA1QtQC9yZnBwoDn51JWXDbaTd/go-ipfs-routing/none"
46 offroute "gx/ipfs/QmQ9PR61a8rwEFuFNs7JMA1QtQC9yZnBwoDn51JWXDbaTd/go-ipfs-routing/offline"
47 + psrouter "gx/ipfs/QmQ9qNWAZDDoPYenvsMwoyh4ZrJFZdbfGTVDuZkxUcJKp1/go-libp2p-pubsub-router"
48 exchange "gx/ipfs/QmR1nncPsZR14A4hWr39mq8Lm7BGgS68bHVT9nop8NpWEM/go-ipfs-exchange-interface"
49 goprocess "gx/ipfs/QmSF8fPo3jgVBAy8fpdjjYqgG87dkJgUprRBHRd2tmfgpP/goprocess"
50 mamask "gx/ipfs/QmSMZwvs3n4GBikZ7hKzT17c3bk65FmyZo2JqtJ16swqCv/multiaddr-filter"
@@ -53,12 +54,10 @@ import (
54 config "gx/ipfs/QmSoYrBMibm2T3LupaLuez7LPGnyrJwdRxvTfPUyCp691u/go-ipfs-config"
55 dht "gx/ipfs/QmSteomMgXnSQxLEY5UpxmkYAd8QF9JuLLeLYBokTHxFru/go-libp2p-kad-dht"
56 dhtopts "gx/ipfs/QmSteomMgXnSQxLEY5UpxmkYAd8QF9JuLLeLYBokTHxFru/go-libp2p-kad-dht/opts"
56 - floodsub "gx/ipfs/QmTcC9Qx2adsdGguNpqZ6dJK7MMsH8sf3yfxZxG3bSwKet/go-libp2p-floodsub"
57 merkledag "gx/ipfs/QmVvNkTCx8V9Zei8xuTYTBdUXmbnDRS4iNuw1SztYyhQwQ/go-merkledag"
58 yamux "gx/ipfs/QmVwYCtShoL74Xi8TgEg9jXvHVVtWwZ3Hg1QZqQvQA9xji/go-smux-yamux"
59 ft "gx/ipfs/QmWE6Ftsk98cG2MTVgH4wJT8VP2nL9TuBkYTrz9GSqcsh5/go-unixfs"
60 pstore "gx/ipfs/QmWtCpWB39Rzc2xTB75MKorsxNpo3TyecTEN24CJ3KVohE/go-libp2p-peerstore"
61 - psrouter "gx/ipfs/QmX5cToCpsigs7ZebYjm8P8aQN5A6Mx9LydrrSyBBtevzn/go-libp2p-pubsub-router"
61 bitswap "gx/ipfs/QmXBT58TaD2CJThpHy4xkxC1xsW4hXWBGZuKMepwjuzJ5B/go-bitswap"
62 bsnet "gx/ipfs/QmXBT58TaD2CJThpHy4xkxC1xsW4hXWBGZuKMepwjuzJ5B/go-bitswap/network"
63 pnet "gx/ipfs/QmY4Q5JC4vxLEi8EpVxJM4rcRryEVtH1zRKVTAm6BKV1pg/go-libp2p-pnet"
@@ -75,6 +74,7 @@ import (
74 bstore "gx/ipfs/QmcDDgAXDbpDUpadCJKLr49KYR4HuL7T8Z1dZTHt6ixsoR/go-ipfs-blockstore"
75 ipld "gx/ipfs/QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL/go-ipld-format"
76 "gx/ipfs/QmdrpbDgeYH3VxkCciQCJY5LkDYdXtig6unDzQmMxFtWEw/go-path/resolver"
77 + pubsub "gx/ipfs/QmdxgseTjZvbvEKGbpnSitR6oCCanRZiSiqjn1SC4pb7Wy/go-libp2p-pubsub"
78 mfs "gx/ipfs/Qmf5gumjmXpwmn7uDfAvkXbFQ5sHGGbJGccS8znSYmDQaz/go-mfs"
79 p2phost "gx/ipfs/Qmf5yHzmWAyHSJRPAmZzfk3Yd7icydBLi7eec5741aov7v/go-libp2p-host"
80 )
@@ -137,7 +137,7 @@ type IpfsNode struct {
137 Reprovider *rp.Reprovider // the value reprovider system
138 IpnsRepub *ipnsrp.Republisher
139
140 - Floodsub *floodsub.PubSub
140 + PubSub *pubsub.PubSub
141 PSRouter *psrouter.PubsubValueStore
142 DHT *dht.IpfsDHT
143 P2P *p2p.P2P
@@ -459,26 +459,26 @@ func (n *IpfsNode) HandlePeerFound(p pstore.PeerInfo) {
459
460 // startOnlineServicesWithHost is the set of services which need to be
461 // initialized with the host and _before_ we start listening.
462 -func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost.Host, routingOption RoutingOption, pubsub bool, ipnsps bool) error {
462 +func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost.Host, routingOption RoutingOption, enablePubsub bool, enableIpnsps bool) error {
463 // setup diagnostics service
464 n.Ping = ping.NewPingService(host)
465
466 - if pubsub || ipnsps {
466 + if enablePubsub || enableIpnsps {
467 cfg, err := n.Repo.Config()
468 if err != nil {
469 return err
470 }
471
472 - var service *floodsub.PubSub
472 + var service *pubsub.PubSub
473
474 switch cfg.Pubsub.Router {
475 case "":
476 fallthrough
477 case "floodsub":
478 - service, err = floodsub.NewFloodSub(ctx, host)
478 + service, err = pubsub.NewFloodSub(ctx, host)
479
480 case "gossipsub":
481 - service, err = floodsub.NewGossipSub(ctx, host)
481 + service, err = pubsub.NewGossipSub(ctx, host)
482
483 default:
484 err = fmt.Errorf("Unknown pubsub router %s", cfg.Pubsub.Router)
@@ -487,7 +487,7 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost
487 if err != nil {
488 return err
489 }
490 - n.Floodsub = service
490 + n.PubSub = service
491 }
492
493 // setup routing service
@@ -514,12 +514,12 @@ func (n *IpfsNode) startOnlineServicesWithHost(ctx context.Context, host p2phost
514 n.DHT = dht
515 }
516
517 - if ipnsps {
517 + if enableIpnsps {
518 n.PSRouter = psrouter.NewPubsubValueStore(
519 ctx,
520 host,
521 n.Routing,
522 - n.Floodsub,
522 + n.PubSub,
523 n.RecordValidator,
524 )
525 n.Routing = rhelpers.Tiered{
core/coreapi/pubsub.go
+8 -8
@@ -12,20 +12,20 @@ import (
12 caopts "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
13
14 cid "gx/ipfs/QmPSQnBKM9g7BaUcZCvswUJVscQ1ipjmwxN5PXCjkp9EQ7/go-cid"
15 - floodsub "gx/ipfs/QmTcC9Qx2adsdGguNpqZ6dJK7MMsH8sf3yfxZxG3bSwKet/go-libp2p-floodsub"
15 pstore "gx/ipfs/QmWtCpWB39Rzc2xTB75MKorsxNpo3TyecTEN24CJ3KVohE/go-libp2p-peerstore"
16 peer "gx/ipfs/QmbNepETomvmXfz1X5pHNFD2QuPqnqi47dTd94QJWSorQ3/go-libp2p-peer"
17 + pubsub "gx/ipfs/QmdxgseTjZvbvEKGbpnSitR6oCCanRZiSiqjn1SC4pb7Wy/go-libp2p-pubsub"
18 )
19
20 type PubSubAPI CoreAPI
21
22 type pubSubSubscription struct {
23 cancel context.CancelFunc
24 - subscription *floodsub.Subscription
24 + subscription *pubsub.Subscription
25 }
26
27 type pubSubMessage struct {
28 - msg *floodsub.Message
28 + msg *pubsub.Message
29 }
30
31 func (api *PubSubAPI) Ls(ctx context.Context) ([]string, error) {
@@ -33,7 +33,7 @@ func (api *PubSubAPI) Ls(ctx context.Context) ([]string, error) {
33 return nil, err
34 }
35
36 - return api.node.Floodsub.GetTopics(), nil
36 + return api.node.PubSub.GetTopics(), nil
37 }
38
39 func (api *PubSubAPI) Peers(ctx context.Context, opts ...caopts.PubSubPeersOption) ([]peer.ID, error) {
@@ -46,7 +46,7 @@ func (api *PubSubAPI) Peers(ctx context.Context, opts ...caopts.PubSubPeersOptio
46 return nil, err
47 }
48
49 - peers := api.node.Floodsub.ListPeers(settings.Topic)
49 + peers := api.node.PubSub.ListPeers(settings.Topic)
50 out := make([]peer.ID, len(peers))
51
52 for i, peer := range peers {
@@ -61,7 +61,7 @@ func (api *PubSubAPI) Publish(ctx context.Context, topic string, data []byte) er
61 return err
62 }
63
64 - return api.node.Floodsub.Publish(topic, data)
64 + return api.node.PubSub.Publish(topic, data)
65 }
66
67 func (api *PubSubAPI) Subscribe(ctx context.Context, topic string, opts ...caopts.PubSubSubscribeOption) (coreiface.PubSubSubscription, error) {
@@ -71,7 +71,7 @@ func (api *PubSubAPI) Subscribe(ctx context.Context, topic string, opts ...caopt
71 return nil, err
72 }
73
74 - sub, err := api.node.Floodsub.Subscribe(topic)
74 + sub, err := api.node.PubSub.Subscribe(topic)
75 if err != nil {
76 return nil, err
77 }
@@ -122,7 +122,7 @@ func (api *PubSubAPI) checkNode() error {
122 return coreiface.ErrOffline
123 }
124
125 - if api.node.Floodsub == nil {
125 + if api.node.PubSub == nil {
126 return errors.New("experimental pubsub feature not enabled. Run daemon with --enable-pubsub-experiment to use.")
127 }
128
package.json
+8 -8
@@ -181,12 +181,6 @@
181 "name": "hang-fds",
182 "version": "0.0.12"
183 },
184 - {
185 - "author": "whyrusleeping",
186 - "hash": "QmTcC9Qx2adsdGguNpqZ6dJK7MMsH8sf3yfxZxG3bSwKet",
187 - "name": "go-libp2p-floodsub",
188 - "version": "0.9.36"
189 - },
184 {
185 "author": "whyrusleeping",
186 "hash": "QmdDXJs4axxefSPgK6Y1QhpJWKuDPnGJiqgq4uncb4rFHL",
@@ -464,9 +458,9 @@
458 },
459 {
460 "author": "stebalien",
467 - "hash": "QmX5cToCpsigs7ZebYjm8P8aQN5A6Mx9LydrrSyBBtevzn",
461 + "hash": "QmQ9qNWAZDDoPYenvsMwoyh4ZrJFZdbfGTVDuZkxUcJKp1",
462 "name": "go-libp2p-pubsub-router",
469 - "version": "0.4.11"
463 + "version": "0.4.12"
464 },
465 {
466 "author": "Stebalien",
@@ -586,6 +580,12 @@
580 "hash": "QmZMWMvWMVKCbHetJ4RgndbuEF1io2UpUxwQwtNjtYPzSC",
581 "name": "go-ipfs-files",
582 "version": "1.0.1"
583 + },
584 + {
585 + "author": "whyrusleeping",
586 + "hash": "QmdxgseTjZvbvEKGbpnSitR6oCCanRZiSiqjn1SC4pb7Wy",
587 + "name": "go-libp2p-pubsub",
588 + "version": "0.10.0"
589 }
590 ],
591 "gxVersion": "0.10.0",