Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrStateNotSynchronized indicates the state database may be empty ErrStateNotSynchronized = errors.New("state not synchronized") )
Functions ¶
func InitContext ¶ added in v0.0.4
InitContext initializes DB connection by the given config
func RunMigrationsUp ¶
RunMigrationsUp runs migrate-up for the given config.
Types ¶
type Config ¶
type Config struct {
// Database name
Name string `mapstructure:"Name"`
// Database User name
User string `mapstructure:"User"`
// Database Password of the user
Password string `mapstructure:"Password"`
// Host address of database
Host string `mapstructure:"Host"`
// Port Number of database
Port string `mapstructure:"Port"`
// EnableLog
// DEPRECATED
EnableLog bool `mapstructure:"EnableLog"`
// MaxConns is the maximum number of connections in the pool.
MaxConns int `mapstructure:"MaxConns"`
}
Config provide fields to configure the pool
type DB ¶
type DB interface {
BeginStateTransaction(ctx context.Context) (Tx, error)
Exists(ctx context.Context, key common.Hash) bool
GetLastProcessedBlock(ctx context.Context, task string) (uint64, error)
GetOffChainData(ctx context.Context, key common.Hash, dbTx sqlx.QueryerContext) (types.ArgBytes, error)
StoreLastProcessedBlock(ctx context.Context, task string, block uint64, dbTx sqlx.ExecerContext) error
StoreOffChainData(ctx context.Context, od []types.OffChainData, dbTx sqlx.ExecerContext) error
}
DB defines functions that a DB instance should implement
type Tx ¶ added in v0.0.4
type Tx interface {
sqlx.ExecerContext
sqlx.QueryerContext
driver.Tx
}
Tx is the interface that defines functions a db tx has to implement
Click to show internal directories.
Click to hide internal directories.