base

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package base provides the base model for all models.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllModels

func GetAllModels() (allModels []interface{})

GetAllModels gets all models to migrate see: https://medium.com/@SaifAbid/slice-interfaces-8c78f8b6345d for an explanation of why we can't do this at initialization time

Types

type InterchainTransaction

type InterchainTransaction struct {
	// TransactionID is the transaction id.
	TransactionID string `gorm:"column:transaction_id;primaryKey"`
	// SrcChainID is the source chain id.
	SrcChainID uint64 `gorm:"column:src_chain_id;index"`
	// DstChainID is the destination chain id.
	DstChainID uint64 `gorm:"column:dst_chain_id;index"`
	// Status is the status of the transaction.
	Status db.ExecutableStatus `gorm:"column:status;index"`
	// GasAirdrop is the gas airdrop of the transaction.
	GasAirdrop string `gorm:"column:gas_airdrop;index"`
	// Options is the gas limit of the transaction.
	GasLimit string `gorm:"column:gas_limit;index"`
	// EncodedTx is the encoded transaction.
	EncodedTx string `gorm:"column:encoded_tx"`
}

InterchainTransaction is the interchain transaction model.

func (InterchainTransaction) ToTransactionSent

func (s InterchainTransaction) ToTransactionSent() (db.TransactionSent, error)

ToTransactionSent converts the interchain transaction to a transaction sent.

type LastIndexed

type LastIndexed struct {
	// CreatedAt is the creation time
	CreatedAt time.Time
	// UpdatedAt is the update time
	UpdatedAt time.Time
	// DeletedAt time
	DeletedAt gorm.DeletedAt `gorm:"index"`
	// ChainID is the chain id of the chain we're watching blocks on. This is our primary index.
	ChainID uint64 `gorm:"column:chain_id;primaryKey;autoIncrement:false"`
	// BlockHeight is the highest height we've seen on the chain
	BlockNumber int `gorm:"block_number"`
}

LastIndexed is used to make sure we haven't missed any events while offline. since we event source - rather than use a state machine this is needed to make sure we haven't missed any events by allowing us to go back and source any events we may have missed.

this does not inherit from gorm.model to allow us to use ChainID as a primary key.

type Store

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

Store implements the service.

func NewStore

func NewStore(db *gorm.DB, metrics metrics.Handler) *Store

NewStore creates a new store.

func (Store) DB

func (s Store) DB() *gorm.DB

DB gets the database object for mutation outside of the lib.

func (Store) GetInterchainTXsByStatus

func (s Store) GetInterchainTXsByStatus(ctx context.Context, matchStatuses ...db.ExecutableStatus) (res []db.TransactionSent, err error)

GetInterchainTXsByStatus gets the interchain transactions by status.

func (Store) LatestBlockForChain

func (s Store) LatestBlockForChain(ctx context.Context, chainID uint64) (uint64, error)

LatestBlockForChain gets the latest block for a chain.

func (Store) PutLatestBlock

func (s Store) PutLatestBlock(ctx context.Context, chainID, height uint64) error

PutLatestBlock upserts the latest block into the database.

func (Store) StoreInterchainTransaction

func (s Store) StoreInterchainTransaction(ctx context.Context, originChainID *big.Int, interchainTx *interchainclient.InterchainClientV1InterchainTransactionSent, options *interchainclient.OptionsV1, encodedTX []byte) error

StoreInterchainTransaction stores the interchain transaction.

func (Store) SubmitterDB

func (s Store) SubmitterDB() submitterDB.Service

SubmitterDB gets the submitter database object for mutation outside of the lib.

func (Store) UpdateInterchainTransactionStatus

func (s Store) UpdateInterchainTransactionStatus(ctx context.Context, transactionid [32]byte, status db.ExecutableStatus) error

UpdateInterchainTransactionStatus updates the interchain transaction status.

Jump to

Keyboard shortcuts

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