global

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const StakePubkeyIndexFileName = "stake_pubkeys.idx"

StakePubkeyIndexFileName is the name of the stake pubkey index file

Variables

This section is empty.

Functions

func BankhashConfirmedForSlot

func BankhashConfirmedForSlot(slot uint64, bankHash solana.Hash) int

func BlockHeight

func BlockHeight() uint64

func CalcUnixTimeForClockSysvar

func CalcUnixTimeForClockSysvar() bool

func ClearEpochStakes

func ClearEpochStakes(epoch uint64)

ClearEpochStakes removes all stakes for a specific epoch. Used on resume to force rebuild from AccountsDB.

func ClearEpochVoteStateSnapshots

func ClearEpochVoteStateSnapshots()

func ClearPendingStakePubkeys

func ClearPendingStakePubkeys()

ClearPendingStakePubkeys discards any pending stake pubkeys without writing them. Used for rollback on failed block replay.

func CompactStakePubkeyIndex

func CompactStakePubkeyIndex(accountsDbDir string) error

CompactStakePubkeyIndex rewrites the index file from the cached deduplicated entries. Only triggers when at least compactThreshold entries have been appended since last compaction. Should be called at epoch boundary when the cache is already populated.

func DeleteVoteCacheItem

func DeleteVoteCacheItem(pubkey solana.PublicKey)

func DeserializeAndLoadEpochStakes

func DeserializeAndLoadEpochStakes(data []byte) (uint64, error)

DeserializeAndLoadEpochStakes deserializes and loads epoch stakes from JSON. Returns the epoch number that was loaded.

func EnqueuePendingStakePubkey

func EnqueuePendingStakePubkey(pubkey solana.PublicKey)

EnqueuePendingStakePubkey records a stake pubkey for later append to the index file. Called during tx processing when a stake account is created or modified. Deduplication happens at index load time (LoadStakePubkeyIndex keeps last occurrence).

func Epoch

func Epoch() uint64

func EpochAuthorizedVoters

func EpochAuthorizedVoters() *epochstakes.EpochAuthorizedVotersCache

func EpochStakes

func EpochStakes(epoch uint64) map[solana.PublicKey]uint64

func EpochStakesVoteAccts

func EpochStakesVoteAccts(epoch uint64) map[solana.PublicKey]*epochstakes.VoteAccount

func EpochTotalStake

func EpochTotalStake(epoch uint64) uint64

func EpochVoteStateSnapshot

func EpochVoteStateSnapshot(epoch uint64) map[solana.PublicKey]*sealevel.VoteStateVersions

func FlushPendingStakePubkeys

func FlushPendingStakePubkeys(accountsDbDir string) (int, error)

FlushPendingStakePubkeys appends any new stake entries discovered during replay to the stake pubkey index file. Called after each block commit. Writes 48-byte records to match the header written at snapshot time. Returns the number of entries flushed.

func GetAllCachedEpochs

func GetAllCachedEpochs() []uint64

GetAllCachedEpochs returns all epochs currently in the epoch stakes cache.

func HasEpochStakes

func HasEpochStakes(epoch uint64) bool

func HasForkChoice

func HasForkChoice() bool

func IncrTransactionCount

func IncrTransactionCount(num uint64)

func LatestBlockHash

func LatestBlockHash() [32]byte

func LeaderForSlot

func LeaderForSlot(slot uint64) (solana.PublicKey, bool)

func LoadStakePubkeyIndex

func LoadStakePubkeyIndex(accountsDbDir string) ([]accountsdb.StakeIndexEntry, error)

LoadStakePubkeyIndex reads the stake pubkey index file, auto-detecting format. Returns deduplicated entries sorted by (FileId, Offset) for sequential I/O. Results are cached after first load; subsequent calls return the cached slice. IMPORTANT: The returned slice is shared — callers must NOT mutate it. Legacy format: 32-byte pubkeys with no location hints (FileId=0, Offset=0). Current format: 8-byte header ("STKI" + version) + 48-byte records (pubkey + fileId + offset).

func ManageLeaderSchedule

func ManageLeaderSchedule() bool

func PutEpochAuthorizedVoter

func PutEpochAuthorizedVoter(voteAcct solana.PublicKey, authorizedVoter solana.PublicKey)

func PutEpochStakesEntry

func PutEpochStakesEntry(epoch uint64, pubkey solana.PublicKey, stake uint64, voteAcct *epochstakes.VoteAccount)

func PutEpochTotalStake

func PutEpochTotalStake(epoch uint64, totalStake uint64)

func PutEpochVoteStateSnapshot

func PutEpochVoteStateSnapshot(epoch uint64, snapshot map[solana.PublicKey]*sealevel.VoteStateVersions)

func PutSlotConfirmed

func PutSlotConfirmed(slot uint64)

func PutVoteCacheItem

func PutVoteCacheItem(pubkey solana.PublicKey, voteState *sealevel.VoteStateVersions)

func SerializeEpochStakes

func SerializeEpochStakes(epoch uint64) ([]byte, error)

SerializeEpochStakes serializes the stakes for a single epoch to JSON.

func SetBlockHeight

func SetBlockHeight(blockHeight uint64)

func SetCalcUnixTimeForClockSysvar

func SetCalcUnixTimeForClockSysvar(calcUnixTime bool)

func SetEpoch

func SetEpoch(epoch uint64)

func SetEpochAuthorizedVoters

func SetEpochAuthorizedVoters(cache *epochstakes.EpochAuthorizedVotersCache)

SetEpochAuthorizedVoters replaces the entire authorized voters cache. Called at epoch boundaries after rebuilding from vote accounts.

func SetForkChoice

func SetForkChoice(forkChoice *forkchoice.ForkChoiceService)

func SetLatestBlockHash

func SetLatestBlockHash(blockHash [32]byte)

func SetLeaderSchedule

func SetLeaderSchedule(ls *leaderschedule.LeaderSchedule)

func SetManageLeaderSchedule

func SetManageLeaderSchedule(manageLeaderSchedule bool)

func SetSlot

func SetSlot(slot uint64)

func Slot

func Slot() uint64

func SlotConfirmed

func SlotConfirmed(slot uint64) bool

func StakeForVoteAcct

func StakeForVoteAcct(epoch uint64, voteAcct solana.PublicKey) uint64

func StreamStakeAccounts

func StreamStakeAccounts(
	acctsDb *accountsdb.AccountsDb,
	slot uint64,
	fn func(pubkey solana.PublicKey, delegation *sealevel.Delegation, creditsObserved uint64),
) (int, error)

StreamStakeAccounts iterates all stake accounts from the pubkey index, calling fn for each valid delegation. Returns count of processed accounts. This streams directly from AccountsDB without building a full stake cache. Entries are sorted by (FileId, Offset) and batched by FileId for sequential I/O.

func SubmitBlockToForkChoiceService

func SubmitBlockToForkChoiceService(slot uint64, txs []*solana.Transaction)

func TransactionCount

func TransactionCount() uint64

func VoteCache

func VoteCache() map[solana.PublicKey]*sealevel.VoteStateVersions

func VoteCacheItem

func VoteCacheItem(pubkey solana.PublicKey) *sealevel.VoteStateVersions

func VoteCacheSnapshot

func VoteCacheSnapshot() map[solana.PublicKey]*sealevel.VoteStateVersions

Types

type GlobalCtx

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

func (*GlobalCtx) BlockHeight

func (globctx *GlobalCtx) BlockHeight() uint64

func (*GlobalCtx) Epoch

func (globctx *GlobalCtx) Epoch() uint64

func (*GlobalCtx) IncrTransactionCount

func (globctx *GlobalCtx) IncrTransactionCount(num uint64)

func (*GlobalCtx) LatestBlockhash

func (globctx *GlobalCtx) LatestBlockhash() [32]byte

func (*GlobalCtx) SetBlockHeight

func (globctx *GlobalCtx) SetBlockHeight(blockHeight uint64)

func (*GlobalCtx) SetEpoch

func (globctx *GlobalCtx) SetEpoch(epoch uint64)

func (*GlobalCtx) SetLatestBlockhash

func (globctx *GlobalCtx) SetLatestBlockhash(blockhash [32]byte)

func (*GlobalCtx) SetSlot

func (globctx *GlobalCtx) SetSlot(slot uint64)

func (*GlobalCtx) Slot

func (globctx *GlobalCtx) Slot() uint64

func (*GlobalCtx) TransactionCount

func (globctx *GlobalCtx) TransactionCount() uint64

Jump to

Keyboard shortcuts

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