Documentation
¶
Index ¶
- Constants
- func WithLoaders(ctx context.Context, client LiteClient) context.Context
- type GetPoolDataConfigTlb
- type GetPoolDataTlb
- type LiteClient
- type PackedNominatorData
- type RawPastElection
- type RetryExclude
- type RoundRobinClient
- func (r *RoundRobinClient) GetAccountState(ctx context.Context, accountID ton.AccountID) (tlb.ShardAccount, error)
- func (r *RoundRobinClient) GetBlock(ctx context.Context, blockID ton.BlockIDExt) (tlb.Block, error)
- func (r *RoundRobinClient) GetConfigParams(ctx context.Context, mode liteapi.ConfigMode, paramList []uint32) (tlb.ConfigParams, error)
- func (r *RoundRobinClient) GetMasterchainInfo(ctx context.Context) (liteclient.LiteServerMasterchainInfoC, error)
- func (r *RoundRobinClient) LookupBlock(ctx context.Context, blockID ton.BlockID, mode uint32, lt *uint64, ...) (ton.BlockIDExt, tlb.BlockInfo, error)
- func (r *RoundRobinClient) RunSmcMethod(ctx context.Context, accountID ton.AccountID, method string, ...) (uint32, tlb.VmStack, error)
- func (r *RoundRobinClient) RunSmcMethodByID(ctx context.Context, accountID ton.AccountID, methodID int, params tlb.VmStack) (uint32, tlb.VmStack, error)
- func (r *RoundRobinClient) WithBlock(block ton.BlockIDExt) LiteClient
- type Service
- func (s *Service) FetchPerBlockRewards(ctx context.Context, seqno *uint32, unixtime *uint32, shallow bool) (*model.Output, error)
- func (s *Service) FetchRoundRewards(ctx context.Context, query model.RoundRewardsQuery, shallow bool) (*model.RoundRewardsOutput, error)
- func (s *Service) FetchValidationRounds(ctx context.Context, query model.RoundsQuery) (*model.ValidationRoundsOutput, error)
- type Stats
Constants ¶
const ( PastElFieldElectionID = 0 PastElFieldFrozenDict = 4 PastElFieldTotalStake = 5 PastElFieldBonuses = 6 )
past_elections tuple layout from elector-code.fc: [election_id, unfreeze_at, stake_held, vset_hash, frozen_dict, total_stake, bonuses, complaints] https://github.com/ton-blockchain/ton/blob/master/crypto/smartcont/elector-code.fc
Variables ¶
This section is empty.
Functions ¶
func WithLoaders ¶
func WithLoaders(ctx context.Context, client LiteClient) context.Context
WithLoaders creates a new context with dataloaders backed by the given client.
Types ¶
type GetPoolDataConfigTlb ¶
type GetPoolDataTlb ¶
type GetPoolDataTlb struct {
State int8 // ds~load_uint(8), ;; state
NominatorsCount uint16 // ds~load_uint(16), ;; nominators_count
StakeAmountSent tlb.Coins // ds~load_coins(), ;; stake_amount_sent
ValidatorAmount tlb.Coins // ds~load_coins(), ;; validator_amount
Config GetPoolDataConfigTlb `tlb:"^"` // unpack_config(ds~load_ref().begin_parse()), ;; config
Nominators tlb.Maybe[tlb.Ref[tlb.Hashmap[tlb.Bits256, PackedNominatorData]]] // ds~load_dict(), ;; nominators
WithdrawRequests tlb.Maybe[tlb.Ref[tlb.Hashmap[tlb.Bits256, any]]] // ds~load_dict(), ;; withdraw_requests
StakeAt uint32 // ds~load_uint(32), ;; stake_at
SavedValidatorSetHash tlb.Bits256 // ds~load_uint(256), ;; saved_validator_set_hash
ValidatorSetChangesCount uint8 // ds~load_uint(8), ;; validator_set_changes_count
ValidatorSetChangeTime uint32 // ds~load_uint(32), ;; validator_set_change_time
StakeHeldFor uint32 // ds~load_uint(32), ;; stake_held_for
ConfigProposalVotings tlb.Maybe[tlb.Ref[tlb.Hashmap[tlb.Bits256, any]]] // ds~load_dict() ;; config_proposal_votings
}
type LiteClient ¶
type LiteClient interface {
GetMasterchainInfo(context.Context) (liteclient.LiteServerMasterchainInfoC, error)
LookupBlock(context.Context, ton.BlockID, uint32, *uint64, *uint32) (ton.BlockIDExt, tlb.BlockInfo, error)
GetBlock(context.Context, ton.BlockIDExt) (tlb.Block, error)
GetAccountState(context.Context, ton.AccountID) (tlb.ShardAccount, error)
GetConfigParams(context.Context, liteapi.ConfigMode, []uint32) (tlb.ConfigParams, error)
RunSmcMethodByID(context.Context, ton.AccountID, int, tlb.VmStack) (uint32, tlb.VmStack, error)
RunSmcMethod(context.Context, ton.AccountID, string, tlb.VmStack) (uint32, tlb.VmStack, error)
WithBlock(ton.BlockIDExt) LiteClient
}
LiteClient is the interface for blockchain operations. Implemented by RoundRobinClient and used by all service methods.
type PackedNominatorData ¶
type RawPastElection ¶
type RawPastElection struct {
ElectAt int64
FrozenDict tlb.VmStackValue // cell: hashmap of frozen members
TotalStake *big.Int // nil if not available
Bonuses *big.Int // nil if not available
}
RawPastElection holds a single parsed past_elections tuple from the elector contract.
type RetryExclude ¶
type RetryExclude struct {
Excluded map[int]bool // client IDs to exclude for this retry session
LastUsed int // set by client before each request
// contains filtered or unexported fields
}
RetryExclude is a mutable struct passed via context. When a liteserver returns "state already gc'd", the retry loop adds that server to Excluded and retries with a different server. The client sets LastUsed before each request so the retry loop knows which server to exclude.
func WithRetryExclude ¶
func WithRetryExclude(ctx context.Context) (context.Context, *RetryExclude)
WithRetryExclude returns a context with RetryExclude attached for use with retryWithExclude.
type RoundRobinClient ¶
type RoundRobinClient struct {
// contains filtered or unexported fields
}
RoundRobinClient wraps multiple liteapi clients (one per liteserver) and distributes requests across them via round-robin. Unlike the default liteapi pool which routes all traffic through a single "best" connection, this ensures all available connections are utilized.
func NewClient ¶
func NewClient(liteServers []config.LiteServer) (*RoundRobinClient, error)
NewClient creates a round-robin client over liteapi that distributes requests across all available liteserver connections. Unlike the default liteapi pool which routes all traffic through a single "best" connection, this ensures all connections are utilized.
func NewRoundRobinClient ¶
func NewRoundRobinClient(liteServers []config.LiteServer) (*RoundRobinClient, error)
NewRoundRobinClient creates a client that uses one liteapi connection per liteserver and round-robins requests across them.
func (*RoundRobinClient) GetAccountState ¶
func (r *RoundRobinClient) GetAccountState(ctx context.Context, accountID ton.AccountID) (tlb.ShardAccount, error)
func (*RoundRobinClient) GetBlock ¶
func (r *RoundRobinClient) GetBlock(ctx context.Context, blockID ton.BlockIDExt) (tlb.Block, error)
func (*RoundRobinClient) GetConfigParams ¶
func (r *RoundRobinClient) GetConfigParams(ctx context.Context, mode liteapi.ConfigMode, paramList []uint32) (tlb.ConfigParams, error)
func (*RoundRobinClient) GetMasterchainInfo ¶
func (r *RoundRobinClient) GetMasterchainInfo(ctx context.Context) (liteclient.LiteServerMasterchainInfoC, error)
func (*RoundRobinClient) LookupBlock ¶
func (*RoundRobinClient) RunSmcMethod ¶
func (*RoundRobinClient) RunSmcMethodByID ¶
func (*RoundRobinClient) WithBlock ¶
func (r *RoundRobinClient) WithBlock(block ton.BlockIDExt) LiteClient
WithBlock returns a client pinned to the given block for block-specific queries.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service holds the blockchain client and provides validator statistics methods.
func New ¶
func New(client LiteClient, liteServers []config.LiteServer) *Service
New creates a new Service with the given blockchain client.
func (*Service) FetchPerBlockRewards ¶
func (s *Service) FetchPerBlockRewards(ctx context.Context, seqno *uint32, unixtime *uint32, shallow bool) (*model.Output, error)
FetchPerBlockRewards fetches validator statistics for the given seqno (or latest if nil).
func (*Service) FetchRoundRewards ¶
func (s *Service) FetchRoundRewards(ctx context.Context, query model.RoundRewardsQuery, shallow bool) (*model.RoundRewardsOutput, error)
FetchRoundRewards computes per-validator and per-nominator reward distribution for a finished validation round using the elector's bonuses value.
func (*Service) FetchValidationRounds ¶
func (s *Service) FetchValidationRounds(ctx context.Context, query model.RoundsQuery) (*model.ValidationRoundsOutput, error)
FetchValidationRounds returns metadata for past and current validation rounds. It resolves the anchor round sequentially, then estimates middle blocks for remaining rounds and fetches them all in parallel.
type Stats ¶
type Stats struct {
// contains filtered or unexported fields
}
func (*Stats) GetRewardsStats ¶
func (s *Stats) GetRewardsStats() (*oas.RewardsStats, error)