dht

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: Apache-2.0 Imports: 19 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 Client

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

func NewClient

func NewClient(connectTimeout time.Duration, nodes []*Node) (*Client, error)

func NewClientFromConfig

func NewClientFromConfig(ctx context.Context, cfg *liteclient.GlobalConfig) (*Client, error)

func NewClientFromConfigUrl

func NewClientFromConfigUrl(ctx context.Context, 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) FindValue

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

func (*Client) Store

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

func (*Client) StoreAddress

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

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 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"`
}

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