Documentation ¶
Index ¶
- Variables
- func EnsureDB(t *testing.T) (testdb *sql.DB, cleanup func())
- func EnsureSchema(pg *sql.DB) error
- type QueryError
- type Store
- func (s *Store) InsertAccount(ctx context.Context, a *account.RegisterAccountMsg) error
- func (s *Store) InsertBlock(ctx context.Context, b models.Block) error
- func (s *Store) InsertValidator(ctx context.Context, publicKey, address []byte) (int64, error)
- func (s *Store) LastNBlock(ctx context.Context, limit, after int) ([]*models.Block, error)
- func (s *Store) LatestBlock(ctx context.Context) (*models.Block, error)
- func (s *Store) LoadAccount(ctx context.Context, name, domain string) (*models.Account, error)
- func (s *Store) LoadAccountTargets(ctx context.Context, name, domain string) ([]models.AccountTarget, error)
- func (s *Store) LoadBlock(ctx context.Context, blockHeight int64) (*models.Block, error)
- func (s *Store) LoadBlockByHash(ctx context.Context, blockHash string) (*models.Block, error)
- func (s *Store) LoadBlockByHeight(ctx context.Context, blockHeight string) (*models.Block, error)
- func (s *Store) LoadLatestNTx(ctx context.Context, n int) ([]*models.Transaction, error)
- func (s *Store) LoadTx(ctx context.Context, txHash string) (*models.Transaction, error)
- func (s *Store) LoadTxsByMemo(ctx context.Context, memo string) ([]models.Transaction, error)
- func (s *Store) LoadTxsByParams(ctx context.Context, source, dest, memo string) ([]models.Transaction, error)
- func (s *Store) LoadTxsInBlock(ctx context.Context, blockHeight int64) ([]models.Transaction, error)
- func (s *Store) ReplaceAccountTargets(ctx context.Context, a *account.ReplaceAccountTargetsMsg) error
- func (s *Store) ValidatorAddressID(ctx context.Context, address []byte) (int64, error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrConflict is returned when an operation cannot be completed // because of database constraints. ErrConflict = errors.Register(2000, "conflict") // ErrLimit is returned when allowed database query limit is exceeded ErrLimit = errors.Register(2001, "limit") )
Functions ¶
func EnsureDB ¶
ensureDB connects to a Postgres instance creates a database and returns a connection to it. If the connection to Postres cannot be established, the test is skipped.
Each database is initialized with the schema.
Unless an option is provided, defaults are used:
- Database name: test_database_<creation time in unix ns>
- Host: localhost
- Port: 5432
- SSLMode: disable
- User: postgres
Function connects to the 'postgres' database first to create a new database.
func EnsureSchema ¶
Types ¶
type QueryError ¶
func (*QueryError) Error ¶
func (e *QueryError) Error() string
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
func (*Store) InsertAccount ¶ added in v1.1.3
func (*Store) InsertValidator ¶
InsertValidator adds a validator information into the database. It returns the newly created validator ID on success. This method returns ErrConflict if the validator cannot be inserted due to conflicting data.
func (*Store) LastNBlock ¶
LoadLastNBlock returns the last blocks with given count. ErrNotFound is returned if no blocks exist. ErrLimit is returned if allowed limit is exceeded Note that it doesn't load the validators by default
func (*Store) LatestBlock ¶
LatestBlock returns the block with the greatest high value. This method returns ErrNotFound if no block exist. Note that it doesn't load the validators by default
func (*Store) LoadAccount ¶ added in v1.1.3
func (*Store) LoadAccountTargets ¶ added in v1.1.3
func (*Store) LoadBlock ¶
LoadBlock returns the block with the given block height from the database. This method returns ErrNotFound if no block exist. Note that it doesn't load the validators by default
TODO: de-duplicate LatestBlock() code
func (*Store) LoadBlockByHash ¶
func (*Store) LoadBlockByHeight ¶
func (*Store) LoadLatestNTx ¶
LoadLatestNTx
func (*Store) LoadTxsByMemo ¶
LoadTxsByMemo
func (*Store) LoadTxsByParams ¶
func (*Store) LoadTxsInBlock ¶
func (s *Store) LoadTxsInBlock(ctx context.Context, blockHeight int64) ([]models.Transaction, error)
LoadTxsInBlock