record

package
v0.0.0-...-8b9b725 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2019 License: MIT, MIT Imports: 8 Imported by: 36

README

go-libp2p-record

standard-readme compliant

signed records for use with routing systems

Documenation

See https://godoc.org/github.com/libp2p/go-libp2p-record.

Contribute

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

This repository falls under the IPFS Code of Conduct.

Want to hack on IPFS?

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidRecordType = errors.New("invalid record keytype")

ErrInvalidRecordType is returned if a DHTRecord keys prefix is not found in the Validator map of the DHT.

Functions

func MakePutRecord

func MakePutRecord(key string, value []byte) *pb.Record

MakePutRecord creates a dht record for the given key/value pair

func SplitKey

func SplitKey(key string) (string, string, error)

SplitKey takes a key in the form `/$namespace/$path` and splits it into `$namespace` and `$path`.

Types

type NamespacedValidator

type NamespacedValidator map[string]Validator

NamespacedValidator is a validator that delegates to sub-validators by namespace.

func (NamespacedValidator) Select

func (v NamespacedValidator) Select(key string, values [][]byte) (int, error)

Select conforms to the Validator interface.

func (NamespacedValidator) Validate

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

Validate conforms to the Validator interface.

func (NamespacedValidator) ValidatorByKey

func (v NamespacedValidator) ValidatorByKey(key string) Validator

ValidatorByKey looks up the validator responsible for validating the given key.

type PublicKeyValidator

type PublicKeyValidator struct{}

PublicKeyValidator is a Validator that validates public keys.

func (PublicKeyValidator) Select

func (pkv PublicKeyValidator) Select(k string, vals [][]byte) (int, error)

Select conforms to the Validator interface.

It always returns 0 as all public keys are equivalently valid.

func (PublicKeyValidator) Validate

func (pkv PublicKeyValidator) Validate(key string, value []byte) error

Validate conforms to the Validator interface.

It verifies that the passed in record value is the PublicKey that matches the passed in key.

type Validator

type Validator interface {
	// Validate validates the given record, returning an error if it's
	// invalid (e.g., expired, signed by the wrong key, etc.).
	Validate(key string, value []byte) error

	// Select selects the best record from the set of records (e.g., the
	// newest).
	//
	// Decisions made by select should be stable.
	Select(key string, values [][]byte) (int, error)
}

Validator is an interface that should be implemented by record validators.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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