base

package
v0.0.55 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package base contains the base sql implementation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ChainIDFieldName gets the chain id field name.
	ChainIDFieldName string
	// DestinationFieldName is the field name of the destination.
	DestinationFieldName string
	// NonceFieldName is the field name of the tx hash.
	NonceFieldName string
	// RootFieldName is the name of the block number field.
	RootFieldName string
	// BlockNumberFieldName is the index field name.
	BlockNumberFieldName string
)
View Source
var PageSize = 50_000

PageSize is the amount of entries per page of logs.

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

func MessageToDBMessage

func MessageToDBMessage(message Message) types.DBMessage

MessageToDBMessage converts a Message to a DBMessage.

Types

type Message

type Message struct {
	// ChainID is the chain id.
	ChainID uint32 `gorm:"column:chain_id;primaryKey"`
	// Destination is the destination.
	Destination uint32 `gorm:"column:destination;primaryKey"`
	// Nonce is the nonce.
	Nonce uint32 `gorm:"column:nonce;primaryKey"`
	// Root is the root.
	Root string `gorm:"column:root;primaryKey"`
	// Message is the message.
	Message []byte `gorm:"column:message"`
	// BlockNumber is the block number.
	BlockNumber uint64 `gorm:"column:block_number"`
}

Message is the information about a message parsed by the Executor.

func AgentsTypesMessageToMessage

func AgentsTypesMessageToMessage(message agentsTypes.Message, root common.Hash, blockNumber uint64) (Message, error)

AgentsTypesMessageToMessage converts an agentsTypes.Message to a Message.

func DBMessageToMessage

func DBMessageToMessage(dbMessage types.DBMessage) Message

DBMessageToMessage converts a DBMessage to a Message.

type Store

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

Store is the sqlite store. It extends the base store for sqlite specific queries.

func NewStore

func NewStore(db *gorm.DB) *Store

NewStore creates a new store.

func (Store) DB

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

DB gets the database.

func (Store) GetLastBlockNumber

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

GetLastBlockNumber gets the last block number that had a message in the database.

func (Store) GetMessage

func (s Store) GetMessage(ctx context.Context, messageMask types.DBMessage) (*agentsTypes.Message, error)

GetMessage gets a message from the database.

func (Store) GetMessages

func (s Store) GetMessages(ctx context.Context, messageMask types.DBMessage, page int) ([]agentsTypes.Message, error)

GetMessages gets messages from the database, paginated and ordered in ascending order by nonce.

func (Store) GetRoot

func (s Store) GetRoot(ctx context.Context, messageMask types.DBMessage) (common.Hash, error)

GetRoot gets the root of a message from the database.

func (Store) StoreMessage

func (s Store) StoreMessage(ctx context.Context, message agentsTypes.Message, root common.Hash, blockNumber uint64) error

StoreMessage stores a message in the database.

Jump to

Keyboard shortcuts

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