index

package
v0.0.0-...-9808f37 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0, Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ByCheckpoint = iota
	ByLedger     = iota
)

Variables

This section is empty.

Functions

func GetCheckpointNumber

func GetCheckpointNumber(ledger uint32) uint32

GetCheckpointNumber returns the next checkpoint NUMBER (NOT the checkpoint ledger sequence) corresponding to a given ledger sequence.

func GetOperationParticipants

func GetOperationParticipants(transaction ingest.LedgerTransaction, operation xdr.Operation, opIndex int) ([]string, error)

transaction - the ledger transaction operation - the operation within this transaction opIndex - the 0 based index of the operation within the transaction

func GetPaymentParticipants

func GetPaymentParticipants(transaction ingest.LedgerTransaction) ([]string, error)

func GetTransactionParticipants

func GetTransactionParticipants(transaction ingest.LedgerTransaction) ([]string, error)

func PrintProgress

func PrintProgress(prefix string, done, total uint64, startTime time.Time)

func ProcessAccounts

func ProcessAccounts(
	indexStore Store,
	ledger xdr.LedgerCloseMeta,
	tx ingest.LedgerTransaction,
	mode AccountIndexMode,
) error

func ProcessAccountsByCheckpoint

func ProcessAccountsByCheckpoint(
	indexStore Store,
	ledger xdr.LedgerCloseMeta,
	tx ingest.LedgerTransaction,
) error

func ProcessAccountsByCheckpointWithoutBackend

func ProcessAccountsByCheckpointWithoutBackend(
	indexStore Store,
	ledger xdr.LedgerCloseMeta,
	tx ingest.LedgerTransaction,
) error

func ProcessAccountsByLedger

func ProcessAccountsByLedger(
	indexStore Store,
	ledger xdr.LedgerCloseMeta,
	tx ingest.LedgerTransaction,
) error

func ProcessAccountsByLedgerWithoutBackend

func ProcessAccountsByLedgerWithoutBackend(
	indexStore Store,
	ledger xdr.LedgerCloseMeta,
	tx ingest.LedgerTransaction,
) error

func ProcessAccountsWithoutBackend

func ProcessAccountsWithoutBackend(
	indexStore Store,
	ledger xdr.LedgerCloseMeta,
	tx ingest.LedgerTransaction,
	mode AccountIndexMode,
) error

func ProcessTransaction

func ProcessTransaction(
	indexStore Store,
	ledger xdr.LedgerCloseMeta,
	tx ingest.LedgerTransaction,
) error

Types

type AccountIndexMode

type AccountIndexMode int

type IndexBuilder

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

IndexBuilder contains everything needed to build indices from ledger ranges.

func BuildIndices

func BuildIndices(
	ctx context.Context,
	sourceUrl string,
	targetUrl string,
	networkPassphrase string,
	ledgerRange historyarchive.Range,
	modules []string,
	workerCount int,
) (*IndexBuilder, error)

func NewIndexBuilder

func NewIndexBuilder(
	indexStore Store,
	metaArchive metaarchive.MetaArchive,
	networkPassphrase string,
) *IndexBuilder

func (*IndexBuilder) Build

func (builder *IndexBuilder) Build(ctx context.Context, ledgerRange historyarchive.Range) error

Build sequentially creates indices for each ledger in the given range based on the registered modules.

TODO: We can probably optimize this by doing GetLedger in parallel with the ingestion & index building, since the network will be idle during the latter portion.

func (*IndexBuilder) RegisterModule

func (builder *IndexBuilder) RegisterModule(module Module)

RegisterModule adds a module to process every given ledger. It is not threadsafe and all calls should be made *before* any calls to `Build`.

func (*IndexBuilder) RunModules

func (builder *IndexBuilder) RunModules(
	ledger xdr.LedgerCloseMeta,
	tx ingest.LedgerTransaction,
) error

RunModules executes all of the registered modules on the given ledger.

func (*IndexBuilder) Watch

func (builder *IndexBuilder) Watch(ctx context.Context) error

type MockStore

type MockStore struct {
	mock.Mock
}

func (*MockStore) AddParticipantToIndexesNoBackend

func (m *MockStore) AddParticipantToIndexesNoBackend(participant string, indexes types.NamedIndices)

func (*MockStore) AddParticipantsToIndexes

func (m *MockStore) AddParticipantsToIndexes(checkpoint uint32, index string, participants []string) error

func (*MockStore) AddParticipantsToIndexesNoBackend

func (m *MockStore) AddParticipantsToIndexesNoBackend(checkpoint uint32, index string, participants []string) error

func (*MockStore) AddTransactionToIndexes

func (m *MockStore) AddTransactionToIndexes(txnTOID int64, hash [32]byte) error

func (*MockStore) ClearMemory

func (m *MockStore) ClearMemory(arg bool)

func (*MockStore) Flush

func (m *MockStore) Flush() error

func (*MockStore) FlushAccounts

func (m *MockStore) FlushAccounts() error

func (*MockStore) MergeTransactions

func (m *MockStore) MergeTransactions(prefix string, other *types.TrieIndex) error

func (*MockStore) NextActive

func (m *MockStore) NextActive(account, index string, afterCheckpoint uint32) (uint32, error)

func (*MockStore) Read

func (m *MockStore) Read(account string) (types.NamedIndices, error)

func (*MockStore) ReadAccounts

func (m *MockStore) ReadAccounts() ([]string, error)

func (*MockStore) ReadTransactions

func (m *MockStore) ReadTransactions(prefix string) (*types.TrieIndex, error)

func (*MockStore) RegisterMetrics

func (m *MockStore) RegisterMetrics(registry *prometheus.Registry)

func (*MockStore) TransactionTOID

func (m *MockStore) TransactionTOID(hash [32]byte) (int64, error)

type Module

type Module func(
	indexStore Store,
	ledger xdr.LedgerCloseMeta,
	transaction ingest.LedgerTransaction,
) error

Module is a way to process ingested data and shove it into an index store.

type Store

type Store interface {
	NextActive(account, index string, afterCheckpoint uint32) (uint32, error)
	TransactionTOID(hash [32]byte) (int64, error)

	AddTransactionToIndexes(txnTOID int64, hash [32]byte) error
	AddParticipantsToIndexes(checkpoint uint32, index string, participants []string) error
	AddParticipantsToIndexesNoBackend(checkpoint uint32, index string, participants []string) error
	AddParticipantToIndexesNoBackend(participant string, indexes types.NamedIndices)

	Flush() error
	FlushAccounts() error
	ClearMemory(bool)

	Read(account string) (types.NamedIndices, error)
	ReadAccounts() ([]string, error)
	ReadTransactions(prefix string) (*types.TrieIndex, error)

	MergeTransactions(prefix string, other *types.TrieIndex) error

	RegisterMetrics(registry *prometheus.Registry)
}

func Connect

func Connect(backendUrl string) (Store, error)

func ConnectWithConfig

func ConnectWithConfig(config StoreConfig) (Store, error)

func NewFileStore

func NewFileStore(prefix string, config StoreConfig) (Store, error)

func NewS3Store

func NewS3Store(awsConfig *aws.Config, bucket string, prefix string, indexConfig StoreConfig) (Store, error)

func NewStore

func NewStore(backend backend.Backend, config StoreConfig) (Store, error)

type StoreConfig

type StoreConfig struct {
	// init time config
	// the base url for the store resource
	URL string
	// optional url path to append to the base url to realize the complete url
	URLSubPath string
	Workers    uint32

	// runtime config
	ClearMemoryOnFlush bool

	// logging & metrics
	Log     *log.Entry // TODO: unused for now
	Metrics *prometheus.Registry
}

Directories

Path Synopsis
cmd
batch
Package batch provides two commands: map and reduce that can be run in AWS Batch to generate indexes for occurences of accounts in each checkpoint.
Package batch provides two commands: map and reduce that can be run in AWS Batch to generate indexes for occurences of accounts in each checkpoint.

Jump to

Keyboard shortcuts

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