database

package
v0.0.0-...-8c125ef Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorRowNotFound = errors.New("row not found")
)

Functions

This section is empty.

Types

type Client

type Client interface {
	Session
	Transaction

	RollbackBlock(ctx context.Context, chainID, blockNUmber uint64) error

	FindCheckpoint(ctx context.Context, chainID uint64) (*schema.Checkpoint, error)
	SaveCheckpoint(ctx context.Context, checkpoint *schema.Checkpoint) error

	SaveBillingRecordDeposited(ctx context.Context, billingRecord *schema.BillingRecordDeposited) error
	SaveBillingRecordWithdrawal(ctx context.Context, billingRecord *schema.BillingRecordWithdrawal) error
	SaveBillingRecordCollected(ctx context.Context, billingRecord *schema.BillingRecordCollected) error

	PrepareBillingCollectTokens(ctx context.Context, nowTime time.Time, epoch *big.Int) (*map[common.Address]schema.BillingCollectDataPerAddress, error)
	PrepareBillingWithdrawTokens(ctx context.Context) (*map[common.Address]float64, error)
	UpdateBillingRuLimit(ctx context.Context, succeededUsersWithRu map[common.Address]int64) error

	GatewayDeposit(ctx context.Context, address common.Address, ruIncrease int64) (bool, error)

	FindNodeRequestRewardsByEpoch(ctx context.Context, epoch *big.Int) ([]*schema.NodeRequestRecord, error)
	SaveNodeRequestCount(ctx context.Context, record *schema.NodeRequestRecord) error
	SetNodeRequestRewards(ctx context.Context, epoch *big.Int, nodeAddr common.Address, reward *big.Int) error

	Raw() *gorm.DB
}

type Driver

type Driver string
const (
	DriverPostgreSQL Driver = "postgresql"
	DriverMySQL      Driver = "mysql"
)

type Session

type Session interface {
	Migrate(ctx context.Context) error
	WithTransaction(ctx context.Context, transactionFunction func(ctx context.Context, client Client) error, transactionOptions ...*sql.TxOptions) error
	Begin(ctx context.Context, transactionOptions ...*sql.TxOptions) (Client, error)
}

type SugaredLogger

type SugaredLogger struct {
	Logger *zap.SugaredLogger
}

func (SugaredLogger) Fatalf

func (s SugaredLogger) Fatalf(format string, v ...interface{})

func (SugaredLogger) Printf

func (s SugaredLogger) Printf(format string, v ...interface{})

type Transaction

type Transaction interface {
	Rollback() error
	Commit() error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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