usecases

package
v0.0.0-...-1fa16a9 Latest Latest
Warning

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

Go to latest
Published: May 26, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blockchain

type Blockchain interface {
	Start(ctx context.Context)
	Shutdown(ctx context.Context)
	GetLatestBlockNumber(ctx context.Context) (*big.Int, error)
	GetTokenEvents(context.Context, *big.Int, *big.Int) ([]entities.TokenEvent, error)
}

type Database

type Database interface {
	Start(ctx context.Context)
	Shutdown(ctx context.Context)
	GetLastIndexedBlock(context.Context) (*big.Int, error)
	UpdateLastIndexedBlock(context.Context, *big.Int) error
}

type IndexBlocks

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

func NewIndexBlocksUseCase

func NewIndexBlocksUseCase(
	logger common.Logger,
	settings settings.Settings,
	indexReputation *IndexReputation,
	database Database,
	blockchain Blockchain) *IndexBlocks

func (*IndexBlocks) Execute

func (u *IndexBlocks) Execute(ctx context.Context) error

Execute checks the last block indexed (minus an offset) and the latest block produced and indexes all blocks in between. Executre returns an error if it failed to fully index the blocks. We want to make indexing idempotent and be resilient to re-orgs so we:

  • keep track of last block indexed
  • read events from last block indexed - n to lastest block
  • always delete events that already exist for the same block being inserted (in single tx)

type IndexReputation

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

func NewIndexReputationUseCase

func NewIndexReputationUseCase(logger common.Logger, settings settings.Settings, blockchainGateway Blockchain) *IndexReputation

func (*IndexReputation) Execute

func (u *IndexReputation) Execute(ctx context.Context, fromBlock *big.Int, toBlock *big.Int) error

Jump to

Keyboard shortcuts

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