liteclient

package
v0.0.0-...-bcde84c Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: AGPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoActiveConnections = errors.New("no active connections")
View Source
var (
	ErrNoConnections = errors.New("no connections established")
)

Functions

This section is empty.

Types

type ADNLRequest

type ADNLRequest struct {
	QueryID  []byte
	Data     any
	RespChan chan *ADNLResponse
}

type ADNLResponse

type ADNLResponse struct {
	Data tl.Serializable
	Err  error
}

type ConnectionPool

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

func NewConnectionPool

func NewConnectionPool() *ConnectionPool

NewConnectionPool - ordinary pool to query liteserver

func NewConnectionPoolWithAuth

func NewConnectionPoolWithAuth(key ed25519.PrivateKey) *ConnectionPool

NewConnectionPoolWithAuth - will do TCP authorization after connection, can be used to communicate with storage-daemon

func (*ConnectionPool) AddConnection

func (c *ConnectionPool) AddConnection(ctx context.Context, addr, serverKey string, clientKey ...ed25519.PrivateKey) error

func (*ConnectionPool) AddConnectionsFromConfig

func (c *ConnectionPool) AddConnectionsFromConfig(ctx context.Context, config *GlobalConfig) error

func (*ConnectionPool) AddConnectionsFromConfigUrl

func (c *ConnectionPool) AddConnectionsFromConfigUrl(ctx context.Context, configUrl string) error

func (*ConnectionPool) DefaultReconnect

func (c *ConnectionPool) DefaultReconnect(waitBeforeReconnect time.Duration, maxTries int) OnDisconnectCallback

func (*ConnectionPool) QueryADNL

func (c *ConnectionPool) QueryADNL(ctx context.Context, request tl.Serializable, result tl.Serializable) error

QueryADNL - sends ADNL request to peer

func (*ConnectionPool) QueryLiteserver

func (c *ConnectionPool) QueryLiteserver(ctx context.Context, request tl.Serializable, result tl.Serializable) error

QueryLiteserver - sends request to liteserver

func (*ConnectionPool) SetOnDisconnect

func (c *ConnectionPool) SetOnDisconnect(cb OnDisconnectCallback)

func (*ConnectionPool) StickyContext

func (c *ConnectionPool) StickyContext(ctx context.Context) context.Context

StickyContext - bounds all requests with this context to the same lite-server node, if possible. This is useful when we are doing some requests which depends on each other.

For example: we requested MasterchainInfo from node A, and we are trying to request account with this block info from node B but node B don't have yet information about this block, so it can return error. If we use StickyContext, all requests where its passed will be routed to same node.

In case if sticky node goes down, default balancer will be used as fallback

func (*ConnectionPool) StickyNodeID

func (c *ConnectionPool) StickyNodeID(ctx context.Context) uint32

type DHTAddress

type DHTAddress struct {
	Type string `json:"@type"`
	IP   int    `json:"ip"`
	Port int    `json:"port"`
}

type DHTAddressList

type DHTAddressList struct {
	Type       string       `json:"@type"`
	Addrs      []DHTAddress `json:"addrs"`
	Version    int          `json:"version"`
	ReinitDate int          `json:"reinit_date"`
	Priority   int          `json:"priority"`
	ExpireAt   int          `json:"expire_at"`
}

type DHTConfig

type DHTConfig struct {
	Type        string   `json:"@type"`
	K           int      `json:"k"`
	A           int      `json:"a"`
	StaticNodes DHTNodes `json:"static_nodes"`
}

type DHTNode

type DHTNode struct {
	Type      string         `json:"@type"`
	ID        ServerID       `json:"id"`
	AddrList  DHTAddressList `json:"addr_list"`
	Version   int            `json:"version"`
	Signature string         `json:"signature"`
}

type DHTNodes

type DHTNodes struct {
	Type  string    `json:"@type"`
	Nodes []DHTNode `json:"nodes"`
}

type GlobalConfig

type GlobalConfig struct {
	Type        string             `json:"@type"`
	DHT         DHTConfig          `json:"dht"`
	Liteservers []LiteserverConfig `json:"liteservers"`
	Validator   ValidatorConfig    `json:"validator"`
}

func GetConfigFromUrl

func GetConfigFromUrl(ctx context.Context, url string) (*GlobalConfig, error)

type LiteServerQuery

type LiteServerQuery struct {
	Data any `tl:"bytes struct boxed"`
}

type LiteserverConfig

type LiteserverConfig struct {
	IP   int64    `json:"ip"`
	Port int      `json:"port"`
	ID   ServerID `json:"id"`
}

type NetworkErr

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

func (NetworkErr) Is

func (e NetworkErr) Is(err error) bool

func (NetworkErr) Unwrap

func (e NetworkErr) Unwrap() error

type OnDisconnectCallback

type OnDisconnectCallback func(addr, key string)

type ServerID

type ServerID struct {
	Type string `json:"@type"`
	Key  string `json:"key"`
}

type TCPAuthenticate

type TCPAuthenticate struct {
	Nonce []byte `tl:"bytes"`
}

type TCPAuthenticationComplete

type TCPAuthenticationComplete struct {
	PublicKey any    `tl:"struct boxed [pub.ed25519]"`
	Signature []byte `tl:"bytes"`
}

type TCPAuthenticationNonce

type TCPAuthenticationNonce struct {
	Nonce []byte `tl:"bytes"`
}

type TCPPing

type TCPPing struct {
	RandomID int64 `tl:"long"`
}

type TCPPong

type TCPPong struct {
	RandomID int64 `tl:"long"`
}

type ValidatorConfig

type ValidatorConfig struct {
	Type      string              `json:"@type"`
	ZeroState ValidatorZeroState  `json:"zero_state"`
	InitBlock ValidatorInitBlock  `json:"init_block"`
	Hardforks []ValidatorHardfork `json:"hardforks"`
}

type ValidatorHardfork

type ValidatorHardfork struct {
	FileHash  string `json:"file_hash"`
	Seqno     int    `json:"seqno"`
	RootHash  string `json:"root_hash"`
	Workchain int    `json:"workchain"`
	Shard     int64  `json:"shard"`
}

type ValidatorInitBlock

type ValidatorInitBlock struct {
	RootHash  string `json:"root_hash"`
	Seqno     int    `json:"seqno"`
	FileHash  string `json:"file_hash"`
	Workchain int    `json:"workchain"`
	Shard     int64  `json:"shard"`
}

type ValidatorZeroState

type ValidatorZeroState struct {
	Workchain int    `json:"workchain"`
	Shard     int64  `json:"shard"`
	Seqno     int    `json:"seqno"`
	RootHash  string `json:"root_hash"`
	FileHash  string `json:"file_hash"`
}

Jump to

Keyboard shortcuts

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