record

package module
v4.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2018 License: MIT Imports: 9 Imported by: 0

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 ErrBadRecord = errors.New("bad dht record")

ErrBadRecord is returned any time a dht record is found to be incorrectly formatted or signed.

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 PublicKeySelector

func PublicKeySelector(k string, vals [][]byte) (int, error)

PublicKeySelector just selects the first entry. All valid public key records will be equivalent.

func PublicKeyValidator

func PublicKeyValidator(r *ValidationRecord) error

ValidatePublicKeyRecord implements ValidatorFunc and verifies that the passed in record value is the PublicKey that matches the passed in key.

Types

type Selector

type Selector map[string]SelectorFunc

func (Selector) BestRecord

func (s Selector) BestRecord(k string, recs [][]byte) (int, error)

type SelectorFunc

type SelectorFunc func(string, [][]byte) (int, error)

A SelectorFunc selects the best value for the given key from a slice of possible values and returns the index of the chosen one

type ValidationRecord

type ValidationRecord struct {
	Namespace string
	Key       string
	Value     []byte
}

type Validator

type Validator map[string]ValidatorFunc

Validator is an object that helps ensure routing records are valid. It is a collection of validator functions, each of which implements its own notion of validity.

func (Validator) VerifyRecord

func (v Validator) VerifyRecord(r *pb.Record) error

VerifyRecord checks a record and ensures it is still valid. It runs needed validators. Note that VerifyRecord does not perform signature verification.

type ValidatorFunc

type ValidatorFunc func(*ValidationRecord) error

ValidatorFunc is a function that is called to validate a given type of DHTRecord.

Directories

Path Synopsis
Package record_pb is a generated protocol buffer package.
Package record_pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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