Documentation ¶
Index ¶
- Variables
- func NewSQLDB(cfg Config) (*pgxpool.Pool, error)
- func RunMigrationsDown(pg *pgxpool.Pool) error
- func RunMigrationsUp(pg *pgxpool.Pool) error
- type Config
- type DB
- func (db *DB) BeginStateTransaction(ctx context.Context) (pgx.Tx, error)
- func (db *DB) Exists(ctx context.Context, key common.Hash) bool
- func (db *DB) GetLastProcessedBlock(ctx context.Context) (uint64, error)
- func (db *DB) GetOffChainData(ctx context.Context, key common.Hash, dbTx pgx.Tx) (rpc.ArgBytes, error)
- func (db *DB) ResetLastProcessedBlock(ctx context.Context, block uint64) (uint64, error)
- func (db *DB) StoreLastProcessedBlock(ctx context.Context, block uint64, dbTx pgx.Tx) error
- func (db *DB) StoreOffChainData(ctx context.Context, od []offchaindata.OffChainData, dbTx pgx.Tx) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrStateNotSynchronized indicates the state database may be empty ErrStateNotSynchronized = errors.New("state not synchronized") )
Functions ¶
func RunMigrationsDown ¶
RunMigrationsDown runs migrate-down for 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 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 struct {
// contains filtered or unexported fields
}
DB is the database layer of the data node
func (*DB) BeginStateTransaction ¶
BeginStateTransaction begins a DB transaction. The caller is responsible for committing or rolling back the transaction
func (*DB) GetLastProcessedBlock ¶
GetLastProcessedBlock returns the latest block successfully processed by the synchronizer
func (*DB) GetOffChainData ¶
func (db *DB) GetOffChainData(ctx context.Context, key common.Hash, dbTx pgx.Tx) (rpc.ArgBytes, error)
GetOffChainData returns the value identified by the key
func (*DB) ResetLastProcessedBlock ¶
ResetLastProcessedBlock removes all sync_info for blocks greater than `block`
func (*DB) StoreLastProcessedBlock ¶
StoreLastProcessedBlock stores a record of a block processed by the synchronizer
func (*DB) StoreOffChainData ¶
func (db *DB) StoreOffChainData(ctx context.Context, od []offchaindata.OffChainData, dbTx pgx.Tx) error
StoreOffChainData stores and array of key values in the Db