mvc

package
v21.0.0-a-rc3-testnet Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Encapsulates the Model-View-Controller abstraction domain. Separated from the rest of the domain to avoid import cycles.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtomicIngester

type AtomicIngester interface {
	// ProcessBlock processes the block by writing data into a transaction.
	// Returns error if fails to process.
	// It does not flush data to sink. The caller must call Exec on the transaction
	ProcessBlock(ctx sdk.Context, tx Tx) error

	SetLogger(log.Logger)
}

AtomicIngester is an interface that defines the methods for the atomic ingester. It processes a block by writing data into a transaction. The caller must call Exec on the transaction to flush data to sink.

type ChainInfoRepository

type ChainInfoRepository interface {
	// StoreLatestHeight stores the latest blockchain height
	StoreLatestHeight(ctx context.Context, tx Tx, height uint64) error

	// GetLatestHeight retrieves the latest blockchain height
	GetLatestHeight(ctx context.Context) (uint64, error)

	// GetLatestHeightRetrievalTime retrieves the latest blockchain height retrieval time.
	GetLatestHeightRetrievalTime(ctx context.Context) (time.Time, error)

	// StoreLatestHeightRetrievalTime stores the latest blockchain height retrieval time.
	StoreLatestHeightRetrievalTime(ctx context.Context, time time.Time) error
}

ChainInfoRepository represents the contract for a repository handling chain information

type ChainInfoUsecase

type ChainInfoUsecase interface {
	GetLatestHeight(ctx context.Context) (uint64, error)
}

type PoolsRepository

type PoolsRepository interface {
	// GetAllPools atomically reads and returns all on-chain pools sorted by ID.
	// Note that this does NOT return tick models for the concentrated pools
	GetAllPools(context.Context) ([]domain.PoolI, error)

	// GetPools atomically reads and returns the pools with the given IDs.
	// Note that this does NOT return tick models for the concentrated pools
	GetPools(ctx context.Context, poolIDs map[uint64]struct{}) (map[uint64]domain.PoolI, error)

	GetTickModelForPools(ctx context.Context, pools []uint64) (map[uint64]domain.TickModel, error)

	// StorePools atomically stores the given pools.
	StorePools(ctx context.Context, tx Tx, pools []domain.PoolI) error
	// ClearAllPools atomically clears all pools.
	ClearAllPools(ctx context.Context, tx Tx) error
}

PoolsRepository represent the pool's repository contract

type PoolsUsecase

type PoolsUsecase interface {
	GetAllPools(ctx context.Context) ([]domain.PoolI, error)

	// GetRoutesFromCandidates converts candidate routes to routes intrusmented with all the data necessary for estimating
	// a swap. This data entails the pool data, the taker fee.
	GetRoutesFromCandidates(ctx context.Context, candidateRoutes route.CandidateRoutes, takerFeeMap domain.TakerFeeMap, tokenInDenom, tokenOutDenom string) ([]route.RouteImpl, error)

	GetTickModelMap(ctx context.Context, poolIDs []uint64) (map[uint64]domain.TickModel, error)
}

PoolsUsecase represent the pool's usecases

type RedisTx

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

RedisTx is a redis transaction.

func NewRedisTx

func NewRedisTx(pipeliner redis.Pipeliner) *RedisTx

func (*RedisTx) AsRedisTx

func (rt *RedisTx) AsRedisTx() (*RedisTx, error)

AsRedisTx implements Tx.

func (*RedisTx) ClearAll

func (rt *RedisTx) ClearAll(ctx context.Context) error

ClearAll implements Tx.

func (*RedisTx) Exec

func (rt *RedisTx) Exec(ctx context.Context) error

Exec implements Tx.

func (*RedisTx) GetPipeliner

func (rt *RedisTx) GetPipeliner(ctx context.Context) (redis.Pipeliner, error)

GetPipeliner returns a redis pipeliner for the current transaction. Returns an error if transaction is not in progress.

func (*RedisTx) IsActive

func (rt *RedisTx) IsActive() bool

IsActive implements Tx.

type RouterRepository

type RouterRepository interface {
	GetTakerFee(ctx context.Context, denom0, denom1 string) (osmomath.Dec, error)
	GetAllTakerFees(ctx context.Context) (domain.TakerFeeMap, error)
	SetTakerFee(ctx context.Context, tx Tx, denom0, denom1 string, takerFee osmomath.Dec) error
	// SetRoutesTx sets the routes for the given denoms in the given transaction.
	// Sorts denom0 and denom1 lexicographically before setting the routes.
	// Returns error if the transaction fails.
	SetRoutesTx(ctx context.Context, tx Tx, denom0, denom1 string, routes route.CandidateRoutes) error
	// SetRoutes sets the routes for the given denoms. Creates a new transaction and executes it.
	// Sorts denom0 and denom1 lexicographically before setting the routes.
	// Returns error if the transaction fails.
	SetRoutes(ctx context.Context, denom0, denom1 string, routes route.CandidateRoutes) error
	// GetRoutes returns the routes for the given denoms.
	// Sorts denom0 and denom1 lexicographically before setting the routes.
	// Returns empty slice and no error if no routes are present.
	// Returns error if the routes are not found.
	GetRoutes(ctx context.Context, denom0, denom1 string) (route.CandidateRoutes, error)
}

RouterRepository represent the router's repository contract

type RouterUsecase

type RouterUsecase interface {
	// GetOptimalQuote returns the optimal quote for the given tokenIn and tokenOutDenom.
	GetOptimalQuote(ctx context.Context, tokenIn sdk.Coin, tokenOutDenom string) (domain.Quote, error)
	// GetBestSingleRouteQuote returns the best single route quote for the given tokenIn and tokenOutDenom.
	GetBestSingleRouteQuote(ctx context.Context, tokenIn sdk.Coin, tokenOutDenom string) (domain.Quote, error)
	// GetCustomQuote returns the custom quote for the given tokenIn, tokenOutDenom and poolIDs.
	// It searches for the route that contains the specified poolIDs in the given order.
	// If such route is not found it returns an error.
	GetCustomQuote(ctx context.Context, tokenIn sdk.Coin, tokenOutDenom string, poolIDs []uint64) (domain.Quote, error)
	// GetCandidateRoutes returns the candidate routes for the given tokenIn and tokenOutDenom.
	GetCandidateRoutes(ctx context.Context, tokenInDenom, tokenOutDenom string) (route.CandidateRoutes, error)
	// StoreRoutes stores all router state in the files locally. Used for debugging.
	StoreRouterStateFiles(ctx context.Context) error
}

RouterUsecase represent the router's usecases

type Tx

type Tx interface {
	// Exec executes the transaction.
	// Returns an error if transaction is not in progress.
	Exec(context.Context) error

	// IsActive returns true if transaction is in progress.
	IsActive() bool

	// AsRedisTx returns a redis transaction.
	// Returns an error if this is not a redis transaction.
	AsRedisTx() (*RedisTx, error)

	// ClearAll clears all data. Returns an error if any.
	ClearAll(ctx context.Context) error
}

Tx defines an interface for atomic transaction.

type TxManager

type TxManager interface {
	// StartTx starts a new atomic transaction.
	StartTx() Tx
}

TxManager defines an interface for atomic transaction manager.

Jump to

Keyboard shortcuts

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