base

package
v0.0.84 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 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 AttestationToDBAttestation added in v0.0.63

func AttestationToDBAttestation(attestation Attestation) types.DBAttestation

AttestationToDBAttestation converts an Attestation to a DBAttestation.

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 Attestation added in v0.0.63

type Attestation 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"`
	// DestinationBlockNumber is the block number that the attestation was submitted on the destination.
	DestinationBlockNumber uint64 `gorm:"column:block_number"`
	// DestinationBlockTime is the timestamp of the block that the attestation was submitted on the destination.
	DestinationBlockTime uint64 `gorm:"column:destination_block_time"`
}

Attestation is the information about an attestation parsed by the Executor.

func DBAttestationToAttestation added in v0.0.63

func DBAttestationToAttestation(dbAttestation types.DBAttestation) Attestation

DBAttestationToAttestation converts a DBAttestation to an Attestation.

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"`
	// 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, 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) GetAttestation added in v0.0.63

func (s Store) GetAttestation(ctx context.Context, attestationMask types.DBAttestation) (*agentsTypes.Attestation, error)

GetAttestation gets an attestation from the database.

func (Store) GetAttestationBlockNumber added in v0.0.63

func (s Store) GetAttestationBlockNumber(ctx context.Context, attestationMask types.DBAttestation) (*uint64, error)

GetAttestationBlockNumber gets the block number of an attestation.

func (Store) GetAttestationBlockTime added in v0.0.63

func (s Store) GetAttestationBlockTime(ctx context.Context, attestationMask types.DBAttestation) (*uint64, error)

GetAttestationBlockTime gets the block time of an attestation.

func (Store) GetBlockNumber added in v0.0.63

func (s Store) GetBlockNumber(ctx context.Context, messageMask types.DBMessage) (uint64, error)

GetBlockNumber gets the block number of a message from 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) StoreAttestation added in v0.0.63

func (s Store) StoreAttestation(ctx context.Context, attestation agentsTypes.Attestation, blockNumber uint64, blockTime uint64) error

StoreAttestation stores an attestation.

func (Store) StoreMessage

func (s Store) StoreMessage(ctx context.Context, message agentsTypes.Message, 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