db

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package db implements the data store

Index

Constants

This section is empty.

Variables

View Source
var ErrNoNonceForChain = errors.New("no nonce exists for this chain")

ErrNoNonceForChain indicates that no nonces have been saved for the chain yet.

View Source
var ErrNoNonceForDomain = errors.New("no nonce exists for this domain")

ErrNoNonceForDomain indicates there is no nonce for a domain.

View Source
var ErrNoStoredBlockForChain = errors.New("no block exists for this chain")

ErrNoStoredBlockForChain indicates there are no blocks stored for this domain.

View Source
var ErrNotFound = errors.New("record not found")

ErrNotFound is a not found record standardized across db drivers.

Functions

This section is empty.

Types

type MessageDB

type MessageDB interface {
	// RetrieveLatestCommittedMessageNonce gets the latest nonce of a committed message
	// returns ErrNoNonceForDomain if no nonce exists
	RetrieveLatestCommittedMessageNonce(ctx context.Context, domainID uint32) (nonce uint32, err error)
	// StoreMessageLatestBlockEnd stores the latest block end
	StoreMessageLatestBlockEnd(ctx context.Context, domainID uint32, blockNumber uint32) error
	// GetMessageLatestBlockEnd gets the message latest block
	// returns ErrNoStoredBlockForChain when not present
	GetMessageLatestBlockEnd(ctx context.Context, domainID uint32) (height uint32, err error)
	// StoreCommittedMessage stores a raw committed message
	StoreCommittedMessage(ctx context.Context, domainID uint32, message types.CommittedMessage) error
	// StoreSignedAttestations stores a signed attestation
	StoreSignedAttestations(ctx context.Context, attestation types.SignedAttestation) error
	// RetrieveSignedAttestationByNonce retrieves a signed attestation by nonce
	RetrieveSignedAttestationByNonce(ctx context.Context, domainID, nonce uint32) (attestation types.SignedAttestation, err error)
}

MessageDB stores messages.

type MonitorDB

type MonitorDB interface {
	// StoreDispatchMessage stores a dispatch message
	StoreDispatchMessage(ctx context.Context, message types.Message) error
	// StoreAcceptedAttestation stores an accepted attestation
	StoreAcceptedAttestation(ctx context.Context, destinationDomain uint32, attestation types.Attestation) error
	// GetDelinquentMessage gets messages that were sent, but never received
	GetDelinquentMessages(ctx context.Context, destinationDomain uint32) ([]types.Message, error)
}

MonitorDB stores event data for monitoring.

type SynapseDB

type SynapseDB interface {
	MessageDB
	TxQueueDB
	MonitorDB
}

SynapseDB combines db types.

type TxQueueDB

type TxQueueDB interface {
	// StoreRawTx stores a raw transaction
	StoreRawTx(ctx context.Context, tx *ethTypes.Transaction, chainID *big.Int, from common.Address) error
	// StoreProcessedTx stores a tx that has already been processed
	StoreProcessedTx(ctx context.Context, tx *ethTypes.Transaction) error
	// GetNonceForChainID gets the latest nonce for a sender
	GetNonceForChainID(ctx context.Context, fromAddress common.Address, chainID *big.Int) (nonce uint64, err error)
}

TxQueueDB contains an interface for storing transactions currently being processed.

Directories

Path Synopsis
datastore
sql
Package sql accesses a db
Package sql accesses a db
sql/base
Package base contains the base sql implementation
Package base contains the base sql implementation
sql/mysql
Package mysql implements the mysql package
Package mysql implements the mysql package
sql/sqlite
Package sqlite implements the sqlite package
Package sqlite implements the sqlite package

Jump to

Keyboard shortcuts

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