package module
Version: v0.0.3 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2021 License: MIT Imports: 21 Imported by: 2



GoDoc Coverage Status Build Status Discourse posts

A libp2p router that uses pubsub.

We currently only use this for IPNS over PubSub.




Feel free to join in. All welcome. Open an issue!

This repository falls under the libp2p Code of Conduct.

Want to hack on libp2p?



The last gx published version of this module was: 0.5.18: QmaHVH3EqQD6DsE1yPgwfCThvFCwfkJ396uyrRSo3Ku1kH




View Source
const FetchProtoID = protocol.ID("/p2p/fetch/0.0.1")


This section is empty.


func KeyToTopic

func KeyToTopic(key string) string

KeyToTopic converts a binary record key to a pubsub topic key.


type Option

type Option func(*PubsubValueStore) error

Option is a function that configures a PubsubValueStore during initialization

func WithDatastore

func WithDatastore(datastore ds.Datastore) Option

WithDatastore returns an option that overrides the default datastore.

func WithRebroadcastInitialDelay

func WithRebroadcastInitialDelay(duration time.Duration) Option

func WithRebroadcastInterval

func WithRebroadcastInterval(duration time.Duration) Option

type Pubsub

type Pubsub interface {
	RegisterTopicValidator(topic string, validator interface{}, opts ...pubsub.ValidatorOpt) error
	Join(topic string, opts ...pubsub.TopicOpt) (*pubsub.Topic, error)

Pubsub is the minimal subset of the pubsub interface required by the pubsub value store. This way, users can wrap the underlying pubsub implementation without re-exporting/implementing the entire interface.

type PubsubValueStore

type PubsubValueStore struct {
	Validator record.Validator
	// contains filtered or unexported fields

func NewPubsubValueStore

func NewPubsubValueStore(ctx context.Context, host host.Host, ps Pubsub, validator record.Validator, opts ...Option) (*PubsubValueStore, error)

NewPubsubValueStore constructs a new ValueStore that gets and receives records through pubsub.

func (*PubsubValueStore) Cancel

func (p *PubsubValueStore) Cancel(name string) (bool, error)

Cancel cancels a topic subscription; returns true if an active subscription was canceled

func (*PubsubValueStore) GetSubscriptions

func (p *PubsubValueStore) GetSubscriptions() []string

GetSubscriptions retrieves a list of active topic subscriptions

func (*PubsubValueStore) GetValue

func (p *PubsubValueStore) GetValue(ctx context.Context, key string, opts ...routing.Option) ([]byte, error)

func (*PubsubValueStore) PutValue

func (p *PubsubValueStore) PutValue(ctx context.Context, key string, value []byte, opts ...routing.Option) error

PutValue publishes a record through pubsub

func (*PubsubValueStore) SearchValue

func (p *PubsubValueStore) SearchValue(ctx context.Context, key string, opts ...routing.Option) (<-chan []byte, error)

func (*PubsubValueStore) Subscribe

func (p *PubsubValueStore) Subscribe(key string) error

Source Files


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL