indexdb

package
v0.4.48 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package indexdb provides a Rosetta-specific index of the Flow chain data.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBlockNotIndexed = errors.New("indexdb: block not indexed")
)

Functions

This section is empty.

Types

type AccountInfo

type AccountInfo struct {
	Changes [][2]uint64 `json:"changes"`
	Proxy   bool        `json:"proxy,omitempty"`
}

AccountInfo represents all the balance changes (block height, balance) for an account and whether it's a proxy account or not.

type BalanceData

type BalanceData struct {
	Balance uint64
	Hash    []byte
	Height  uint64
}

BalanceData represents the indexed balance of an account.

type BlockData

type BlockData struct {
	Block        *model.IndexedBlock
	Hash         []byte
	Height       uint64
	ParentHash   []byte
	ParentHeight uint64
}

BlockData represents the indexed data for a block.

type Store

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

Store aggregates the blockchain data for Rosetta API calls.

func New

func New(dir string) *Store

New opens the database at the given directory and returns the corresponding Store.

func (*Store) Accounts

func (s *Store) Accounts() (map[[8]byte]bool, error)

Accounts returns the addresses of all our indexed accounts, and whether the account is a proxy account or not.

func (*Store) AccountsInfo

func (s *Store) AccountsInfo() (map[string]*AccountInfo, error)

AccountsInfo will return a map of the indexed accounts and their corresponding account info.

func (*Store) BalanceByHash

func (s *Store) BalanceByHash(acct []byte, hash []byte) (*BalanceData, error)

BalanceByHash returns the account balance at the given hash.

func (*Store) BalanceByHeight

func (s *Store) BalanceByHeight(acct []byte, height uint64) (*BalanceData, error)

BalanceByHeight returns the account balance at the given height.

func (*Store) BlockByHash

func (s *Store) BlockByHash(hash []byte) (*BlockData, error)

BlockByHash returns the block data for the given hash.

func (*Store) BlockByHeight

func (s *Store) BlockByHeight(height uint64) (*BlockData, error)

BlockByHeight returns the block data for the given height.

func (*Store) ExportAccounts

func (s *Store) ExportAccounts(filename string)

ExportAccounts will export a map of the indexed accounts and their corresponding account info.

func (*Store) Genesis

func (s *Store) Genesis() *model.BlockMeta

Genesis returns the stored genesis block metadata.

func (*Store) HasBalance

func (s *Store) HasBalance(acct []byte, height uint64) (bool, error)

HasBalance returns whether the given account has an indexed balance at the given height.

func (*Store) HashForHeight

func (s *Store) HashForHeight(height uint64) ([]byte, error)

HashForHeight returns the block hash at the given height.

func (*Store) HeightForHash

func (s *Store) HeightForHash(hash []byte) (uint64, error)

HeightForHash returns the block height for the given hash.

func (*Store) Index

func (s *Store) Index(ctx context.Context, height uint64, hash []byte, block *model.IndexedBlock) error

Index indexes the given block data.

func (*Store) Latest

func (s *Store) Latest() *model.BlockMeta

Latest returns the most recently indexed block.

func (*Store) PurgeProxyAccounts

func (s *Store) PurgeProxyAccounts()

PurgeProxyAccounts removes any indexed account balances or proxy account creation heights from the index database.

func (*Store) ResetTo

func (s *Store) ResetTo(base uint64) error

ResetTo drops all indexed data after the given height.

func (*Store) SetGenesis

func (s *Store) SetGenesis(val *model.BlockMeta) error

SetGenesis sets the genesis block metadata and the initial latest block.

Jump to

Keyboard shortcuts

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