pool

package
v1.5.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FailoverPool

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

FailoverPool is a pool of connections to lite servers that implements a failover strategy and in case of failure it'll automatically switch to a working connection.

The failover strategy is as follows: given a list of connections, a pool uses the first connection from the list that is 1. working 2. not more than 1 block behind the head of masterchain.

func NewFailoverPool

func NewFailoverPool(clients []*liteclient.Client) *FailoverPool

NewFailoverPool returns a new instance of a failover pool. The given list of clients is ordered by priority and starts with a connection with the highest priority.

func (*FailoverPool) BestClientByAccountID added in v1.2.1

func (p *FailoverPool) BestClientByAccountID(ctx context.Context, accountID ton.AccountID) (*liteclient.Client, ton.BlockIDExt, error)

BestClientByAccountID returns a liteclient and its known masterchain head.

func (*FailoverPool) BestClientByBlockID added in v1.2.1

func (p *FailoverPool) BestClientByBlockID(ctx context.Context, blockID ton.BlockID) (*liteclient.Client, error)

BestClientByBlockID returns a liteclient and its known masterchain head.

func (*FailoverPool) BestMasterchainClient added in v1.2.1

func (p *FailoverPool) BestMasterchainClient(ctx context.Context) (*liteclient.Client, ton.BlockIDExt, error)

BestMasterchainClient returns a liteclient and its known masterchain head.

func (*FailoverPool) BestMasterchainInfoClient added in v1.2.1

func (p *FailoverPool) BestMasterchainInfoClient() *MasterchainInfoClient

func (*FailoverPool) ConnectionsNumber

func (p *FailoverPool) ConnectionsNumber() int

ConnectionsNumber returns a number of connections in this pool.

func (*FailoverPool) Run

func (p *FailoverPool) Run(ctx context.Context)

func (*FailoverPool) WaitMasterchainSeqno added in v1.2.1

func (p *FailoverPool) WaitMasterchainSeqno(ctx context.Context, seqno uint32, timeout time.Duration) error

type MasterchainInfoClient added in v1.2.1

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

func (*MasterchainInfoClient) LiteServerGetMasterchainInfo added in v1.2.1

func (s *MasterchainInfoClient) LiteServerGetMasterchainInfo(ctx context.Context) (liteclient.LiteServerMasterchainInfoC, error)

func (*MasterchainInfoClient) LiteServerGetMasterchainInfoExt added in v1.2.1

Jump to

Keyboard shortcuts

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