liteclient

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 27 Imported by: 90

Documentation

Index

Constants

View Source
const ADNLQuery int32 = -1265895046
View Source
const ADNLQueryResponse int32 = 262964246
View Source
const LiteServerQuery int32 = 2039219935
View Source
const TCPPing int32 = 1292381082
View Source
const TCPPong int32 = -597034237

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 ConnectionPool added in v1.0.0

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

func NewConnectionPool added in v1.0.0

func NewConnectionPool() *ConnectionPool

func (*ConnectionPool) AddConnection added in v1.0.0

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

func (*ConnectionPool) AddConnectionsFromConfig added in v1.0.0

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

func (*ConnectionPool) AddConnectionsFromConfigUrl added in v1.0.0

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

func (*ConnectionPool) DefaultReconnect added in v1.0.0

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

func (*ConnectionPool) Do added in v1.0.0

func (c *ConnectionPool) Do(ctx context.Context, typeID int32, payload []byte) (*LiteResponse, error)

Do - builds and executes request to liteserver

func (*ConnectionPool) SetOnDisconnect added in v1.0.0

func (c *ConnectionPool) SetOnDisconnect(cb OnDisconnectCallback)

func (*ConnectionPool) StickyContext added in v1.0.0

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

type DHTAddress added in v1.0.0

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

type DHTAddressList added in v1.0.0

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 added in v1.0.0

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

type DHTNode added in v1.0.0

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 added in v1.0.0

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

type GlobalConfig added in v1.0.0

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

func GetConfigFromUrl added in v1.0.0

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

type LiteRequest

type LiteRequest struct {
	TypeID   int32
	QueryID  []byte
	Data     []byte
	RespChan chan *LiteResponse
}

type LiteResponse

type LiteResponse struct {
	TypeID int32
	Data   []byte
	// contains filtered or unexported fields
}

type LiteserverConfig added in v1.0.0

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

type OnDisconnectCallback added in v0.2.0

type OnDisconnectCallback func(addr, key string)

type ServerID added in v1.0.0

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

type ValidatorConfig added in v1.0.0

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

type ValidatorHardfork added in v1.0.0

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 added in v1.0.0

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 added in v1.0.0

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