accountsdb

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: 25 Imported by: 0

Documentation

Index

Constants

View Source
const StakeIndexRecordSize = 48 // 32-byte pubkey + 8-byte fileId + 8-byte offset
View Source
const StakeIndexVersion = uint32(2)

Variables

View Source
var (
	ErrNoAccount = errors.New("ErrNoAccount")

	StoreAccountsWorkers = 128
)
View Source
var StakeIndexMagic = [4]byte{'S', 'T', 'K', 'I'}

StakeIndexMagic is the magic header for stake pubkey index files.

Functions

func BuildIndexEntriesFromAppendVecs

func BuildIndexEntriesFromAppendVecs(data []byte, fileSize uint64, slot uint64, fileId uint64) ([]solana.PublicKey, []AccountIndexEntry, []StakeIndexEntry, error)

BuildIndexEntriesFromAppendVecs parses an appendvec and returns: - pubkeys: all account pubkeys - acctIdxEntries: index entries for each account - stakeEntries: stake account pubkeys with their appendvec location hints

func GetAppendVecDataLen

func GetAppendVecDataLen(f *os.File, offset uint64) (uint64, error)

GetAppendVecDataLen reads only the bytes necessary to determine the length of the append vec. Should be kept in sync with (*AppendVecAccount).Unmarshal.

func NewAccountsIndexPebbleOptions

func NewAccountsIndexPebbleOptions(logger pebble.Logger) *pebble.Options

func WriteStakePubkeyIndex

func WriteStakePubkeyIndex(path string, entries []StakeIndexEntry) error

WriteStakePubkeyIndex writes stake index entries. Format: 8-byte header ("STKI" + version uint32 LE) + N × 48-byte records.

Types

type AccountIndexEntry

type AccountIndexEntry struct {
	Slot   uint64
	FileId uint64
	Offset uint64
}

func UnmarshalAcctIdxEntry

func UnmarshalAcctIdxEntry(data []byte) (*AccountIndexEntry, error)

func (AccountIndexEntry) Marshal

func (entry AccountIndexEntry) Marshal(out *[24]byte)

func (*AccountIndexEntry) Unmarshal

func (entry *AccountIndexEntry) Unmarshal(in *[24]byte)

type AccountsDb

type AccountsDb struct {
	Index            *pebble.DB
	BankHashStore    *pebble.DB
	AcctsDir         string
	LargestFileId    atomic.Uint64
	VoteAcctCache    otter.Cache[solana.PublicKey, *accounts.Account]
	CommonAcctsCache otter.Cache[solana.PublicKey, *accounts.Account]
	ProgramCache     otter.Cache[solana.PublicKey, *ProgramCacheEntry]
	// contains filtered or unexported fields
}

func OpenDb

func OpenDb(accountsDbDir string) (*AccountsDb, error)

func (*AccountsDb) AddProgramToCache

func (accountsDb *AccountsDb) AddProgramToCache(pubkey solana.PublicKey, programEntry *ProgramCacheEntry)

func (*AccountsDb) AllKeys

func (accountsDb *AccountsDb) AllKeys() [][]byte

func (*AccountsDb) CloseDb

func (accountsDb *AccountsDb) CloseDb()

func (*AccountsDb) GetAccount

func (accountsDb *AccountsDb) GetAccount(slot uint64, pubkey solana.PublicKey) (*accounts.Account, error)

func (*AccountsDb) GetAccountsBatch

func (db *AccountsDb) GetAccountsBatch(ctx context.Context, slot uint64, pks []solana.PublicKey) ([]*accounts.Account, error)

func (*AccountsDb) GetBankHashForSlot

func (accountsDb *AccountsDb) GetBankHashForSlot(slot uint64) ([]byte, error)

func (*AccountsDb) InitCaches

func (accountsDb *AccountsDb) InitCaches()

func (*AccountsDb) KeysBetweenPrefixes

func (accountsDb *AccountsDb) KeysBetweenPrefixes(startPrefix uint64, endPrefix uint64) []solana.PublicKey

func (*AccountsDb) MaybeGetProgramFromCache

func (accountsDb *AccountsDb) MaybeGetProgramFromCache(pubkey solana.PublicKey) (*ProgramCacheEntry, bool)

func (*AccountsDb) RemoveProgramFromCache

func (accountsDb *AccountsDb) RemoveProgramFromCache(pubkey solana.PublicKey)

func (*AccountsDb) StoreAccounts

func (accountsDb *AccountsDb) StoreAccounts(
	accts []*accounts.Account,
	slot uint64,
	cb func(),
) error

func (*AccountsDb) StoreBankHashForSlot

func (accountsDb *AccountsDb) StoreBankHashForSlot(slot uint64, bankHash []byte) error

func (*AccountsDb) StoreQueueLen

func (accountsDb *AccountsDb) StoreQueueLen() int

func (*AccountsDb) WaitForStoreWorker

func (accountsDb *AccountsDb) WaitForStoreWorker()

Turns down the store worker. AccountsDb cannot accept writes after this. Should not be called concurrently.

type AppendVecAccount

type AppendVecAccount struct {
	WriteVersion uint64
	DataLen      uint64
	Pubkey       solana.PublicKey
	Lamports     uint64
	RentEpoch    uint64
	Owner        solana.PublicKey
	Executable   bool
	Padding      [7]byte
	Hash         [32]byte
	Data         []byte
}

func (*AppendVecAccount) Marshal

func (acct *AppendVecAccount) Marshal(buf io.Writer) error

func (*AppendVecAccount) MarshalReturningLength

func (acct *AppendVecAccount) MarshalReturningLength(buf io.Writer) (int, error)

func (*AppendVecAccount) ToAccount

func (appendVecAcct *AppendVecAccount) ToAccount() *accounts.Account

func (*AppendVecAccount) Unmarshal

func (acct *AppendVecAccount) Unmarshal(buf io.Reader) error

type ProgramCacheEntry

type ProgramCacheEntry struct {
	Program        *sbpf.Program
	DeploymentSlot uint64
}

type StakeIndexEntry

type StakeIndexEntry struct {
	Pubkey solana.PublicKey
	FileId uint64
	Offset uint64
}

StakeIndexEntry stores a stake account pubkey with its appendvec location hint. The location (FileId, Offset) is used for sorting to achieve sequential I/O. It may be stale; actual reads still go through Pebble for the canonical location.

Jump to

Keyboard shortcuts

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