name

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const Namespace = "multiverse"

Namespace is the pubsub topic namespace.

Variables

This section is empty.

Functions

func TopicForPeerID

func TopicForPeerID(id peer.ID) string

TopicForPeerID returns the topic name for the given peer id.

Types

type Payload

type Payload struct {
	// Value contains the payload data.
	Value []byte
	// Sequence is a version and nonce.
	Sequence uint64
}

Payload contains record data.

type Record

type Record struct {
	// Signature is a signature of the payload.
	Signature []byte

	Payload
}

Record is used for record signatures.

func NewRecord

func NewRecord(value []byte) *Record

NewRecord returns a new record.

func RecordFromCBOR

func RecordFromCBOR(data []byte) (*Record, error)

RecordFromCBOR decodes an envelope from cbor.

func (*Record) Bytes

func (r *Record) Bytes() ([]byte, error)

Bytes returns the raw bytes of the record.

func (*Record) Sign

func (r *Record) Sign(key crypto.PrivKey) error

Sign creates a signature for the record payload.

func (*Record) Verify

func (r *Record) Verify(key crypto.PubKey) (bool, error)

Verify checks if the signature of the payload is valid.

type System

type System struct {
	// contains filtered or unexported fields
}

System performs name resolution.

func NewSystem

func NewSystem(ctx context.Context, host host.Host, router routing.Routing, dstore datastore.Datastore) (*System, error)

NewNameSystem returns a new name system.

func (*System) GetValue

func (s *System) GetValue(ctx context.Context, id peer.ID) (*Record, error)

GetValue returns the latest value for the topic with the given peer id.

func (*System) Publish

func (s *System) Publish(ctx context.Context, key crypto.PrivKey, id cid.Cid) error

Publish advertises the given id to the topic of the peer ID from the private key.

func (*System) PutValue

func (s *System) PutValue(ctx context.Context, id peer.ID, rec *Record) error

PutValue publishes the value under the topic of the given peer id.

func (*System) Resolve

func (s *System) Resolve(ctx context.Context, id peer.ID) (cid.Cid, error)

Resolve returns the latest value from the topic with the given peer ID.

func (*System) Search

func (s *System) Search(ctx context.Context, id peer.ID) (cid.Cid, error)

Search searches for the the latest value from the topic with the given peer ID.

func (*System) SearchValue

func (s *System) SearchValue(ctx context.Context, id peer.ID) (*Record, error)

Search searches for the the latest value from the topic with the given peer ID.

func (*System) Subscribe

func (s *System) Subscribe(id peer.ID) error

Subscribe creates a subscription to the topic of the given peer ID.

func (*System) Unsubscribe

func (s *System) Unsubscribe(id peer.ID) (bool, error)

Unsubscribe cancels a subscription to the topic of the given peer ID.

type Validator

type Validator struct{}

Validator ensures records are valid.

func (Validator) Select

func (v Validator) Select(key string, vals [][]byte) (int, error)

Select finds the best record by comparing sequence numbers.

func (Validator) Validate

func (v Validator) Validate(key string, value []byte) error

Validate ensures that the signature matches the topic id.

Jump to

Keyboard shortcuts

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