base

package
v0.1.29 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package base contains the base sql implementation

Index

Constants

This section is empty.

Variables

View Source
var (
	// AgentRootFieldName is the field name of the agent root.
	AgentRootFieldName string
	// AgentAddressFieldName gets the agent address field name.
	AgentAddressFieldName string
	// BlockNumberFieldName gets the agent block number field name.
	BlockNumberFieldName string
	// AgentStatusRelayedStateFieldName gets the relayable agent status field name.
	AgentStatusRelayedStateFieldName string
	// DomainFieldName gets the agent domain field name.
	DomainFieldName string
	// UpdatedFlagFieldName gets the updated flag field name.
	UpdatedFlagFieldName string
)

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 AgentRoot added in v0.0.239

type AgentRoot struct {
	// AgentRoot is the root of the agent tree.
	AgentRoot string `gorm:"column:agent_root;primaryKey"`
	// BlockNumber is the block number that the agent tree was updated.
	BlockNumber uint64 `gorm:"column:block_number"`
}

AgentRoot is the state of the agent roots on summit.

type AgentTree added in v0.0.239

type AgentTree struct {
	// AgentRoot is the root of the agent tree.
	AgentRoot string `gorm:"column:agent_root;primaryKey"`
	// AgentAddress is the address of the agent for the Merkle proof.
	AgentAddress string `gorm:"column:agent_address;primaryKey"`
	// BlockNumber is the block number that the agent tree was updated (on summit).
	BlockNumber uint64 `gorm:"column:block_number"`
	// Proof is the agent tree proof.
	Proof json.RawMessage `gorm:"column:proof"`
}

AgentTree is the state of an agent tree on Summit.

type RelayableAgentStatus added in v0.0.239

type RelayableAgentStatus struct {
	AgentAddress string `gorm:"column:agent_address"`
	// StaleFlag is the old flag that needs to be updated.
	StaleFlag agentTypes.AgentFlagType `gorm:"column:stale_flag"`
	// UpdatedFlag is the new flag value that should be relayed.
	UpdatedFlag agentTypes.AgentFlagType `gorm:"column:updated_flag"`
	// Domain is the domain of the agent status.
	Domain uint32 `gorm:"column:domain"`
	// AgentStatusRelayedState is the state of the relayable agent status.
	AgentStatusRelayedState agentTypes.AgentStatusRelayedState `gorm:"column:agent_status_relayed_state"`
}

RelayableAgentStatus is used for tracking agent statuses that are out of sync and need to be relayed to a remote chain.

type Store

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

Store is a store that implements an underlying gorm db.

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) GetRelayableAgentStatuses added in v0.0.239

func (s Store) GetRelayableAgentStatuses(ctx context.Context, chainID uint32) ([]agentTypes.AgentTree, error)

GetRelayableAgentStatuses gets the parameters for updating the agent status with the following steps: 1. Load the `AgentTree` table. 2. Filter the rows where the `AgentStatusRelayedState` is `Queued`, and the `Domain` is the given `chainID`. 3. Outer join the `AgentTree` table on the `RelayableAgentStatus` table on the `AgentAddress` fields. 4. Return all fields in the `AgentTree` table as well as `UpdatedFlag` from the `RelayableAgentStatus` table.

func (Store) GetSummitBlockNumberForRoot added in v0.0.239

func (s Store) GetSummitBlockNumberForRoot(ctx context.Context, agentRoot string) (uint64, error)

GetSummitBlockNumberForRoot gets the summit block number for a given agent root.

func (Store) StoreAgentRoot added in v0.0.239

func (s Store) StoreAgentRoot(
	ctx context.Context,
	agentRoot [32]byte,
	blockNumber uint64,
) error

StoreAgentRoot stores an agent root.

func (Store) StoreAgentTree added in v0.0.239

func (s Store) StoreAgentTree(
	ctx context.Context,
	agentRoot [32]byte,
	agentAddress common.Address,
	blockNumber uint64,
	proof [][32]byte,
) error

StoreAgentTree stores an agent tree.

func (Store) StoreRelayableAgentStatus added in v0.0.239

func (s Store) StoreRelayableAgentStatus(
	ctx context.Context,
	agentAddress common.Address,
	staleFlag agentTypes.AgentFlagType,
	updatedFlag agentTypes.AgentFlagType,
	domain uint32,
) error

StoreRelayableAgentStatus stores a relayable agent status.

func (Store) SubmitterDB

func (s Store) SubmitterDB() submitterDB.Service

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

func (Store) UpdateAgentStatusRelayedState added in v0.0.239

func (s Store) UpdateAgentStatusRelayedState(
	ctx context.Context,
	agentAddress common.Address,
	state agentTypes.AgentStatusRelayedState,
) error

UpdateAgentStatusRelayedState updates the state for a RelayableAgentStatus.

Jump to

Keyboard shortcuts

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