Documentation
¶
Index ¶
- Constants
- Variables
- func BuildIndexEntriesFromAppendVecs(data []byte, fileSize uint64, slot uint64, fileId uint64) ([]solana.PublicKey, []AccountIndexEntry, []StakeIndexEntry, error)
- func GetAppendVecDataLen(f *os.File, offset uint64) (uint64, error)
- func NewAccountsIndexPebbleOptions(logger pebble.Logger) *pebble.Options
- func WriteStakePubkeyIndex(path string, entries []StakeIndexEntry) error
- type AccountIndexEntry
- type AccountsDb
- func (accountsDb *AccountsDb) AddProgramToCache(pubkey solana.PublicKey, programEntry *ProgramCacheEntry)
- func (accountsDb *AccountsDb) AllKeys() [][]byte
- func (accountsDb *AccountsDb) CloseDb()
- func (accountsDb *AccountsDb) GetAccount(slot uint64, pubkey solana.PublicKey) (*accounts.Account, error)
- func (db *AccountsDb) GetAccountsBatch(ctx context.Context, slot uint64, pks []solana.PublicKey) ([]*accounts.Account, error)
- func (accountsDb *AccountsDb) GetBankHashForSlot(slot uint64) ([]byte, error)
- func (accountsDb *AccountsDb) InitCaches()
- func (accountsDb *AccountsDb) KeysBetweenPrefixes(startPrefix uint64, endPrefix uint64) []solana.PublicKey
- func (accountsDb *AccountsDb) MaybeGetProgramFromCache(pubkey solana.PublicKey) (*ProgramCacheEntry, bool)
- func (accountsDb *AccountsDb) RemoveProgramFromCache(pubkey solana.PublicKey)
- func (accountsDb *AccountsDb) StoreAccounts(accts []*accounts.Account, slot uint64, cb func()) error
- func (accountsDb *AccountsDb) StoreBankHashForSlot(slot uint64, bankHash []byte) error
- func (accountsDb *AccountsDb) StoreQueueLen() int
- func (accountsDb *AccountsDb) WaitForStoreWorker()
- type AppendVecAccount
- type ProgramCacheEntry
- type StakeIndexEntry
Constants ¶
const StakeIndexRecordSize = 48 // 32-byte pubkey + 8-byte fileId + 8-byte offset
const StakeIndexVersion = uint32(2)
Variables ¶
var ( ErrNoAccount = errors.New("ErrNoAccount") StoreAccountsWorkers = 128 )
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 ¶
GetAppendVecDataLen reads only the bytes necessary to determine the length of the append vec. Should be kept in sync with (*AppendVecAccount).Unmarshal.
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 ¶
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) GetAccountsBatch ¶
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) MarshalReturningLength ¶
func (acct *AppendVecAccount) MarshalReturningLength(buf io.Writer) (int, error)
func (*AppendVecAccount) ToAccount ¶
func (appendVecAcct *AppendVecAccount) ToAccount() *accounts.Account
type ProgramCacheEntry ¶
type StakeIndexEntry ¶
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.