Documentation ¶
Index ¶
- Variables
- type ADNLRequest
- type ADNLResponse
- type ConfigBlock
- type ConnectionPool
- func (c *ConnectionPool) AddConnection(ctx context.Context, addr, serverKey string, clientKey ...ed25519.PrivateKey) error
- func (c *ConnectionPool) AddConnectionsFromConfig(ctx context.Context, config *GlobalConfig) error
- func (c *ConnectionPool) AddConnectionsFromConfigFile(configPath string) error
- func (c *ConnectionPool) AddConnectionsFromConfigUrl(ctx context.Context, configUrl string) error
- func (c *ConnectionPool) DefaultReconnect(waitBeforeReconnect time.Duration, maxTries int) OnDisconnectCallback
- func (c *ConnectionPool) QueryADNL(ctx context.Context, request tl.Serializable, result tl.Serializable) error
- func (c *ConnectionPool) QueryLiteserver(ctx context.Context, request tl.Serializable, result tl.Serializable) error
- func (c *ConnectionPool) SetOnDisconnect(cb OnDisconnectCallback)
- func (c *ConnectionPool) StickyContext(ctx context.Context) context.Context
- func (c *ConnectionPool) StickyContextNextNode(ctx context.Context) (context.Context, error)
- func (c *ConnectionPool) StickyContextNextNodeBalanced(ctx context.Context) (context.Context, error)
- func (c *ConnectionPool) StickyContextWithNodeID(ctx context.Context, nodeId uint32) context.Context
- func (c *ConnectionPool) StickyNodeID(ctx context.Context) uint32
- func (c *ConnectionPool) Stop()
- type DHTAddress
- type DHTAddressList
- type DHTConfig
- type DHTNode
- type DHTNodes
- type GlobalConfig
- type LiteServerQuery
- type LiteserverConfig
- type NetworkErr
- type OfflineClient
- func (o OfflineClient) QueryLiteserver(ctx context.Context, payload tl.Serializable, result tl.Serializable) error
- func (o OfflineClient) StickyContext(ctx context.Context) context.Context
- func (o OfflineClient) StickyContextNextNode(ctx context.Context) (context.Context, error)
- func (o OfflineClient) StickyNodeID(ctx context.Context) uint32
- type OnDisconnectCallback
- type Server
- type ServerClient
- type ServerID
- type TCPAuthenticate
- type TCPAuthenticationComplete
- type TCPAuthenticationNonce
- type TCPPing
- type TCPPong
- type ValidatorConfig
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoActiveConnections = errors.New("no active connections") ErrADNLReqTimeout = errors.New("adnl request timeout") ErrNoNodesLeft = errors.New("no more active nodes left") )
var (
ErrNoConnections = errors.New("no connections established")
)
var ErrOfflineMode = fmt.Errorf("offline mode is used")
var ErrStopped = errors.New("connection pool is closed")
var Logger = log.Println
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
}
type ConfigBlock ¶
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) AddConnectionsFromConfigFile ¶
func (c *ConnectionPool) AddConnectionsFromConfigFile(configPath string) 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) StickyContextNextNode ¶
StickyContextNextNode - select next node in the available list (pseudo random)
func (*ConnectionPool) StickyContextNextNodeBalanced ¶
func (c *ConnectionPool) StickyContextNextNodeBalanced(ctx context.Context) (context.Context, error)
StickyContextNextNodeBalanced - select next node based on its weight and availability
func (*ConnectionPool) StickyContextWithNodeID ¶
func (*ConnectionPool) StickyNodeID ¶
func (c *ConnectionPool) StickyNodeID(ctx context.Context) uint32
func (*ConnectionPool) Stop ¶
func (c *ConnectionPool) Stop()
type DHTAddress ¶
type DHTAddressList ¶
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 GlobalConfig ¶
type GlobalConfig struct { Type string `json:"@type"` DHT DHTConfig `json:"dht"` Liteservers []LiteserverConfig `json:"liteservers"` Validator ValidatorConfig `json:"validator"` }
func GetConfigFromFile ¶
func GetConfigFromFile(filepath string) (*GlobalConfig, error)
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 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 OfflineClient ¶
type OfflineClient struct{}
func NewOfflineClient ¶
func NewOfflineClient() OfflineClient
func (OfflineClient) QueryLiteserver ¶
func (o OfflineClient) QueryLiteserver(ctx context.Context, payload tl.Serializable, result tl.Serializable) error
func (OfflineClient) StickyContext ¶
func (o OfflineClient) StickyContext(ctx context.Context) context.Context
func (OfflineClient) StickyContextNextNode ¶
func (OfflineClient) StickyNodeID ¶
func (o OfflineClient) StickyNodeID(ctx context.Context) uint32
type OnDisconnectCallback ¶
type OnDisconnectCallback func(addr, key string)
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(keys []ed25519.PrivateKey) *Server
func (*Server) SetConnectionHook ¶
func (s *Server) SetConnectionHook(hook func(client *ServerClient) error)
func (*Server) SetDisconnectHook ¶
func (s *Server) SetDisconnectHook(hook func(client *ServerClient))
func (*Server) SetMessageHandler ¶
func (s *Server) SetMessageHandler(handler func(ctx context.Context, client *ServerClient, msg tl.Serializable) error)
type ServerClient ¶
type ServerClient struct {
// contains filtered or unexported fields
}
func (*ServerClient) Close ¶
func (s *ServerClient) Close()
func (*ServerClient) IP ¶
func (s *ServerClient) IP() string
func (*ServerClient) Port ¶
func (s *ServerClient) Port() uint16
func (*ServerClient) Send ¶
func (s *ServerClient) Send(msg tl.Serializable) error
func (*ServerClient) ServerKey ¶
func (s *ServerClient) ServerKey() ed25519.PublicKey
type TCPAuthenticate ¶
type TCPAuthenticate struct {
Nonce []byte `tl:"bytes"`
}
type TCPAuthenticationNonce ¶
type TCPAuthenticationNonce struct {
Nonce []byte `tl:"bytes"`
}
type ValidatorConfig ¶
type ValidatorConfig struct { Type string `json:"@type"` ZeroState ConfigBlock `json:"zero_state"` InitBlock ConfigBlock `json:"init_block"` Hardforks []ConfigBlock `json:"hardforks"` }