dht

package
v0.0.0-...-449a9a0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package dht wraps libp2p Kademlia DHT to provide DID-based Provide/Find for LinkSelf. DHT key design: namespace "/linkself/did/" + base32(sha256(did)). Value: serialized peer.AddrInfo (JSON or binary).

Index

Constants

View Source
const (
	// Namespace for LinkSelf DID records in the DHT.
	Namespace = "linkself"
	// KeyPrefix is the full key prefix for DID records: /linkself/did/
	KeyPrefix = "/" + Namespace + "/did/"
)

Variables

This section is empty.

Functions

func DIDKey

func DIDKey(didStr string) string

DIDKey returns the DHT record key for the given DID (used with PutValue/GetValue).

func FindDID

func FindDID(ctx context.Context, r routing.ValueStore, didStr string) (peer.AddrInfo, error)

FindDID looks up the peer AddrInfo for the given DID in the DHT.

func LinkselfValidator

func LinkselfValidator() record.Validator

LinkselfValidator returns a record.Validator that includes only the linkself namespace. Use with dht.Option: dht.Validator(LinkselfValidator()) for a DHT that only stores linkself records.

func LinkselfValidatorNamespace

func LinkselfValidatorNamespace() record.Validator

LinkselfValidatorNamespace returns the validator for the "linkself" namespace only. Use with dht.NamespacedValidator("linkself", LinkselfValidatorNamespace()) to add to default validators.

func PutDID

func PutDID(ctx context.Context, r routing.ValueStore, didStr string, info peer.AddrInfo) error

PutDID stores the peer AddrInfo for the given DID in the DHT.

Types

This section is empty.

Jump to

Keyboard shortcuts

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