internal

package
v0.0.0-...-ae8e89f Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateEvents

func ValidateEvents(events []*model.EventEntry) error

Types

type BlockStorage

type BlockStorage interface {
	PersistBlockMetas(ctx context.Context, updateWatermark bool, blocks []*api.BlockMetadata, lastBlock *api.BlockMetadata) error
	GetLatestBlock(ctx context.Context, tag uint32) (*api.BlockMetadata, error)
	GetBlockByHash(ctx context.Context, tag uint32, height uint64, blockHash string) (*api.BlockMetadata, error)
	GetBlockByHeight(ctx context.Context, tag uint32, height uint64) (*api.BlockMetadata, error)
	GetBlocksByHeightRange(ctx context.Context, tag uint32, startHeight, endHeight uint64) ([]*api.BlockMetadata, error)
	// GetBlocksByHeights gets blocks by heights. Results is an ordered array that matches the order in `heights` array
	// i.e. if the heights is [100,2,3], it will return the metadata in order: [block 100, block 2, block 3]
	GetBlocksByHeights(ctx context.Context, tag uint32, heights []uint64) ([]*api.BlockMetadata, error)
}

type EventStorage

type EventStorage interface {
	AddEvents(ctx context.Context, eventTag uint32, events []*model.BlockEvent) error
	AddEventEntries(ctx context.Context, eventTag uint32, eventEntries []*model.EventEntry) error
	GetEventByEventId(ctx context.Context, eventTag uint32, eventId int64) (*model.EventEntry, error)
	GetEventsAfterEventId(ctx context.Context, eventTag uint32, eventId int64, maxEvents uint64) ([]*model.EventEntry, error)
	GetEventsByEventIdRange(ctx context.Context, eventTag uint32, minEventId int64, maxEventId int64) ([]*model.EventEntry, error)
	GetMaxEventId(ctx context.Context, eventTag uint32) (int64, error)
	SetMaxEventId(ctx context.Context, eventTag uint32, maxEventId int64) error
	GetFirstEventIdByBlockHeight(ctx context.Context, eventTag uint32, blockHeight uint64) (int64, error)
	GetEventsByBlockHeight(ctx context.Context, eventTag uint32, blockHeight uint64) ([]*model.EventEntry, error)
}

type EventsToChainAdaptor

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

func NewEventsToChainAdaptor

func NewEventsToChainAdaptor() *EventsToChainAdaptor

func (*EventsToChainAdaptor) AppendEvents

func (e *EventsToChainAdaptor) AppendEvents(events []*model.EventEntry) error

func (*EventsToChainAdaptor) PopEventForTailBlock

func (e *EventsToChainAdaptor) PopEventForTailBlock() (*model.EventEntry, error)

type MetaStorage

type MetaStorage interface {
	BlockStorage
	EventStorage
	TransactionStorage
}

type MetaStorageFactory

type MetaStorageFactory interface {
	Create() (Result, error)
}

type MetaStorageFactoryParams

type MetaStorageFactoryParams struct {
	fx.In
	fxparams.Params
	DynamoDB  MetaStorageFactory `name:"metastorage/dynamodb"`
	Firestore MetaStorageFactory `name:"metastorage/firestore"`
}

type Result

type Result struct {
	fx.Out
	BlockStorage       BlockStorage
	EventStorage       EventStorage
	MetaStorage        MetaStorage
	TransactionStorage TransactionStorage
}

func WithMetaStorageFactory

func WithMetaStorageFactory(params MetaStorageFactoryParams) (Result, error)

type TransactionStorage

type TransactionStorage interface {
	// AddTransactions adds or updates a transaction to block number and hash mapping to the storage.
	AddTransactions(ctx context.Context, transaction []*model.Transaction, parallelism int) error

	// GetTransaction returns a slice of model.Transaction objects, representing the blocks'
	// information for the specific transaction.
	//
	// There are two reasons that a transaction could map to multiple blocks:
	// 1. blockchain reorgs
	// 2. protocol by design, e.g. NEAR
	GetTransaction(ctx context.Context, tag uint32, transactionHash string) ([]*model.Transaction, error)
}

Jump to

Keyboard shortcuts

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