Documentation
¶
Index ¶
- Variables
- func CheckRecordSig(r *pb.Record, pk ci.PubKey) error
- func MakePutRecord(sk ci.PrivKey, key key.Key, value []byte, sign bool) (*pb.Record, error)
- func PublicKeySelector(k key.Key, vals [][]byte) (int, error)
- func RecordBlobForSig(r *pb.Record) []byte
- func ValidatePublicKeyRecord(k key.Key, val []byte) error
- type Selector
- type SelectorFunc
- type ValidChecker
- type Validator
- type ValidatorFunc
Constants ¶
This section is empty.
Variables ¶
var ErrBadRecord = errors.New("bad dht record")
ErrBadRecord is returned any time a dht record is found to be incorrectly formatted or signed.
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.
var PublicKeyValidator = &ValidChecker{
Func: ValidatePublicKeyRecord,
Sign: false,
}
Functions ¶
func CheckRecordSig ¶ added in v0.2.3
func CheckRecordSig(r *pb.Record, pk ci.PubKey) error
func MakePutRecord ¶
func MakePutRecord(sk ci.PrivKey, key key.Key, value []byte, sign bool) (*pb.Record, error)
MakePutRecord creates and signs a dht record for the given key/value pair
func PublicKeySelector ¶ added in v0.3.8
func PublicKeySelector(k key.Key, vals [][]byte) (int, error)
PublicKeySelector just selects the first entry. All valid public key records will be equivalent.
func RecordBlobForSig ¶
func RecordBlobForSig(r *pb.Record) []byte
RecordBlobForSig returns the blob protected by the record signature
func ValidatePublicKeyRecord ¶
func ValidatePublicKeyRecord(k key.Key, val []byte) error
ValidatePublicKeyRecord implements ValidatorFunc and verifies that the passed in record value is the PublicKey that matches the passed in key.
Types ¶
type Selector ¶ added in v0.3.8
type Selector map[string]SelectorFunc
func (Selector) BestRecord ¶ added in v0.3.8
func (s Selector) BestRecord(k key.Key, recs [][]byte) (int, error)
type SelectorFunc ¶ added in v0.3.8
type SelectorFunc func(key.Key, [][]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 ValidChecker ¶ added in v0.2.3
type ValidChecker struct {
Func ValidatorFunc
Sign bool
}
type Validator ¶
type Validator map[string]*ValidChecker
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
type ValidatorFunc ¶
type ValidatorFunc func(key.Key, []byte) error
ValidatorFunc is a function that is called to validate a given type of DHTRecord.