guarddb

package
v1.39.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package guarddb contains the database interface for the rfq guard. All data store types must confrm to this interface.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoProvenForID means the proven was not found.
	ErrNoProvenForID = errors.New("no proven found for tx id")
	// ErrNoBridgeRequestForID means the bridge request was not found.
	ErrNoBridgeRequestForID = errors.New("no bridge request found for tx id")
)

Functions

This section is empty.

Types

type BridgeRequest

type BridgeRequest struct {
	TransactionID [32]byte
	Transaction   fastbridge.IFastBridgeBridgeTransaction
	RawRequest    []byte
}

BridgeRequest is the bridge request object.

type PendingProven

type PendingProven struct {
	Origin         uint32
	RelayerAddress common.Address
	TransactionID  [32]byte
	TxHash         common.Hash
	Status         PendingProvenStatus
	BlockNumber    uint64
}

PendingProven is the pending proven object.

type PendingProvenStatus

type PendingProvenStatus uint8

PendingProvenStatus is the status of a quote request in the db. This is the primary mechanism for moving data through the app.

TODO: consider making this an interface and exporting that.

EXTREMELY IMPORTANT: DO NOT ADD NEW VALUES TO THIS ENUM UNLESS THEY ARE AT THE END.

const (
	// ProveCalled means the prove() function has been called.
	ProveCalled PendingProvenStatus = iota + 1
	// Validated means the prove() call has been properly validated on the dest chain.
	Validated
	// DisputePending means dispute() has been called in the event of an invalid prove().
	DisputePending
	// Disputed means the dispute() call has been confirmed.
	Disputed
)

func (PendingProvenStatus) GormDataType

func (q PendingProvenStatus) GormDataType() string

GormDataType implements the gorm common interface for enums.

func (PendingProvenStatus) Int

func (q PendingProvenStatus) Int() uint8

Int returns the int value of the quote request status.

func (*PendingProvenStatus) Scan

func (q *PendingProvenStatus) Scan(src any) error

Scan implements the gorm common interface for enums.

func (PendingProvenStatus) String

func (i PendingProvenStatus) String() string

func (PendingProvenStatus) Value

func (q PendingProvenStatus) Value() (driver.Value, error)

Value implements the gorm common interface for enums.

type Reader

type Reader interface {
	// GetPendingProvensByStatus gets pending provens by status.
	GetPendingProvensByStatus(ctx context.Context, matchStatuses ...PendingProvenStatus) ([]*PendingProven, error)
	// GetPendingProvenByID gets a pending proven by id. Should return ErrNoProvenForID if not found
	GetPendingProvenByID(ctx context.Context, id [32]byte) (*PendingProven, error)
	// GetBridgeRequestByID gets a bridge request by id. Should return ErrNoBridgeRequestForID if not found
	GetBridgeRequestByID(ctx context.Context, id [32]byte) (*BridgeRequest, error)
}

Reader is the interface for reading from the database.

type Service

type Service interface {
	Reader
	// SubmitterDB returns the submitter database service.
	SubmitterDB() submitterDB.Service
	Writer
	db.ChainListenerDB
}

Service is the interface for the database service.

type Writer

type Writer interface {
	// StoreBridgeRequest stores a bridge request.
	StoreBridgeRequest(ctx context.Context, request BridgeRequest) error
	// StorePendingProven stores a pending proven.
	StorePendingProven(ctx context.Context, proven PendingProven) error
	// UpdatePendingProvenStatus updates the status of a pending proven.
	UpdatePendingProvenStatus(ctx context.Context, id [32]byte, status PendingProvenStatus) error
}

Writer is the interface for writing to the database.

Directories

Path Synopsis
Package base contains the base implementation for different sql driers.
Package base contains the base implementation for different sql driers.
Package connect contains the database connection logic for the RFQ relayer.
Package connect contains the database connection logic for the RFQ relayer.
Package mysql provides a common interface for starting mysql databases
Package mysql provides a common interface for starting mysql databases
Package sqlite provides a common interface for starting sql-lite databases
Package sqlite provides a common interface for starting sql-lite databases

Jump to

Keyboard shortcuts

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