dht

package
v1.9.7 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: Apache-2.0 Imports: 20 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDHTValueIsNotFound = errors.New("value is not found")
View Source
var Logger = func(v ...any) {}

Functions

This section is empty.

Types

type ADNL

type ADNL interface {
	Query(ctx context.Context, req, result tl.Serializable) error
	SetDisconnectHandler(handler func(addr string, key ed25519.PublicKey))
	Close()
}

type Bucket added in v1.9.0

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

type Client

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

func NewClient

func NewClient(gateway Gateway, nodes []*Node) (*Client, error)

func NewClientFromConfig

func NewClientFromConfig(gateway Gateway, cfg *liteclient.GlobalConfig) (*Client, error)

func NewClientFromConfigUrl

func NewClientFromConfigUrl(ctx context.Context, gateway Gateway, cfgUrl string) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) FindAddresses

func (c *Client) FindAddresses(ctx context.Context, key []byte) (*address.List, ed25519.PublicKey, error)

func (*Client) FindOverlayNodes added in v1.6.0

func (c *Client) FindOverlayNodes(ctx context.Context, overlayKey []byte, continuation ...*Continuation) (*overlay.NodesList, *Continuation, error)

func (*Client) FindValue

func (c *Client) FindValue(ctx context.Context, key *Key, continuation ...*Continuation) (*Value, *Continuation, error)

func (*Client) Store

func (c *Client) Store(
	ctx context.Context,
	id any,
	name []byte,
	index int32,
	value []byte,
	rule any,
	ttl time.Duration,
	ownerKey ed25519.PrivateKey,
	_ int,
) (_ int, idKey []byte, err error)

func (*Client) StoreAddress

func (c *Client) StoreAddress(
	ctx context.Context,
	addresses address.List,
	ttl time.Duration,
	ownerKey ed25519.PrivateKey,
	replicas int,
) (replicasMade int, idKey []byte, err error)

func (*Client) StoreOverlayNodes added in v1.7.1

func (c *Client) StoreOverlayNodes(
	ctx context.Context,
	overlayKey []byte,
	nodes *overlay.NodesList,
	ttl time.Duration,
	replicas int,
) (replicasMade int, idKey []byte, err error)

type Continuation added in v1.6.0

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

Continuation allows to check value on the next nodes. Suitable for overlays, different DHT nodes may contain different node addresses. Can be used in case of everything is offline in single DHT node, to check another values.

type FindNode

type FindNode struct {
	Key []byte `tl:"int256"`
	K   int32  `tl:"int"`
}

type FindValue

type FindValue struct {
	Key []byte `tl:"int256"`
	K   int32  `tl:"int"`
}

type Gateway added in v1.6.0

type Gateway interface {
	Close() error
	GetID() []byte
	RegisterClient(addr string, key ed25519.PublicKey) (adnl.Peer, error)
}

type Key

type Key struct {
	ID    []byte `tl:"int256"`
	Name  []byte `tl:"bytes"`
	Index int32  `tl:"int"`
}

type KeyDescription

type KeyDescription struct {
	Key        Key    `tl:"struct"`
	ID         any    `tl:"struct boxed [pub.ed25519,pub.aes,pub.unenc,pub.overlay]"`
	UpdateRule any    `tl:"struct boxed [dht.updateRule.signature,dht.updateRule.anybody,dht.updateRule.overlayNodes]"`
	Signature  []byte `tl:"bytes"`
}

type Node

type Node struct {
	ID        any           `tl:"struct boxed [pub.ed25519,pub.aes]"`
	AddrList  *address.List `tl:"struct"`
	Version   int32         `tl:"int"`
	Signature []byte        `tl:"bytes"`
}

func (*Node) CheckSignature added in v1.6.0

func (n *Node) CheckSignature() error

type NodeInfo

type NodeInfo struct {
	Address string
	Key     ed25519.PublicKey
}

type NodesList

type NodesList struct {
	List []*Node `tl:"vector struct"`
}

type Ping

type Ping struct {
	ID int64 `tl:"long"`
}

type Pong

type Pong struct {
	ID int64 `tl:"long"`
}

type Query

type Query struct {
	Node *Node `tl:"struct"`
}

type SignedAddressListQuery

type SignedAddressListQuery struct{}

type Store

type Store struct {
	Value *Value `tl:"struct"`
}

type Stored

type Stored struct{}

type UpdateRuleAnybody

type UpdateRuleAnybody struct{}

type UpdateRuleOverlayNodes

type UpdateRuleOverlayNodes struct{}

type UpdateRuleSignature

type UpdateRuleSignature struct{}

type Value

type Value struct {
	KeyDescription KeyDescription `tl:"struct"`
	Data           []byte         `tl:"bytes"`
	TTL            int32          `tl:"int"`
	Signature      []byte         `tl:"bytes"`
}

type ValueFoundResult

type ValueFoundResult struct {
	Value Value `tl:"struct boxed"`
}

type ValueNotFoundResult

type ValueNotFoundResult struct {
	Nodes NodesList `tl:"struct"`
}

Jump to

Keyboard shortcuts

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