-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ipns(pubsub): utilize persistent pubsub value store
- Loading branch information
1 parent
6eb481c
commit 36494e4
Showing
6 changed files
with
54 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
package libp2p | ||
|
||
import ( | ||
host "github.com/libp2p/go-libp2p-core/host" | ||
"github.com/libp2p/go-libp2p-core/discovery" | ||
"github.com/libp2p/go-libp2p-core/host" | ||
pubsub "github.com/libp2p/go-libp2p-pubsub" | ||
"go.uber.org/fx" | ||
|
||
"github.com/ipfs/go-ipfs/core/node/helpers" | ||
) | ||
|
||
func FloodSub(pubsubOptions ...pubsub.Option) interface{} { | ||
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host) (service *pubsub.PubSub, err error) { | ||
return pubsub.NewFloodSub(helpers.LifecycleCtx(mctx, lc), host, pubsubOptions...) | ||
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, disc discovery.Discovery) (service *pubsub.PubSub, err error) { | ||
return pubsub.NewFloodSub(helpers.LifecycleCtx(mctx, lc), host, append(pubsubOptions, pubsub.WithDiscovery(disc))...) | ||
} | ||
} | ||
|
||
func GossipSub(pubsubOptions ...pubsub.Option) interface{} { | ||
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host) (service *pubsub.PubSub, err error) { | ||
return pubsub.NewGossipSub(helpers.LifecycleCtx(mctx, lc), host, pubsubOptions...) | ||
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, disc discovery.Discovery) (service *pubsub.PubSub, err error) { | ||
return pubsub.NewGossipSub(helpers.LifecycleCtx(mctx, lc), host, append(pubsubOptions, pubsub.WithDiscovery(disc))...) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package libp2p | ||
|
||
import ( | ||
"math/rand" | ||
"time" | ||
|
||
"github.com/libp2p/go-libp2p-core/discovery" | ||
"github.com/libp2p/go-libp2p-core/host" | ||
disc "github.com/libp2p/go-libp2p-discovery" | ||
|
||
"github.com/ipfs/go-ipfs/core/node/helpers" | ||
"go.uber.org/fx" | ||
) | ||
|
||
func TopicDiscovery() interface{} { | ||
return func(mctx helpers.MetricsCtx, lc fx.Lifecycle, host host.Host, cr BaseIpfsRouting) (service discovery.Discovery, err error) { | ||
baseDisc := disc.NewRoutingDiscovery(cr) | ||
minBackoff, maxBackoff := time.Second*60, time.Hour | ||
rng := rand.New(rand.NewSource(rand.Int63())) | ||
d, err := disc.NewBackoffDiscovery( | ||
baseDisc, | ||
disc.NewExponentialBackoff(minBackoff, maxBackoff, disc.FullJitter, time.Second, 5.0, 0, rng), | ||
) | ||
|
||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return d, nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters