mirror of
https://github.com/alexgo-io/gaze-indexer.git
synced 2026-01-12 08:34:28 +08:00
* feat: recover nodesale module. * fix: refactored. * fix: fix table type. * fix: add entity * fix: bug UTC time. * ci: try to tidy before testing * ci: touch result file * ci: use echo to create new file * fix: try to skip test in ci * fix: remove os.Exit * fix: handle error * feat: add todo note * fix: Cannot run nodesale test because qtx is not initiated. * fix: 50% chance public key compare incorrectly. * fix: more consistent SQL * fix: sanity refactor. * fix: remove unused code. * fix: move last_block_default to config file. * fix: minor mistakes. * fix: * fix: refactor * fix: refactor * fix: delegate tx hash not record into db. * refactor: prepare for moving integration tests. * refactor: convert to unit tests. * fix: change to using input values since output values deducted fee. * feat: add extra unit test. * fix: wrong timestamp format. * fix: handle block timeout = 0 --------- Co-authored-by: Gaze <gazenw@users.noreply.github.com>
63 lines
1.5 KiB
Go
63 lines
1.5 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.26.0
|
|
// source: blocks.sql
|
|
|
|
package gen
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
const createBlock = `-- name: CreateBlock :exec
|
|
INSERT INTO blocks ("block_height", "block_hash", "module")
|
|
VALUES ($1, $2, $3)
|
|
`
|
|
|
|
type CreateBlockParams struct {
|
|
BlockHeight int64
|
|
BlockHash string
|
|
Module string
|
|
}
|
|
|
|
func (q *Queries) CreateBlock(ctx context.Context, arg CreateBlockParams) error {
|
|
_, err := q.db.Exec(ctx, createBlock, arg.BlockHeight, arg.BlockHash, arg.Module)
|
|
return err
|
|
}
|
|
|
|
const getBlock = `-- name: GetBlock :one
|
|
SELECT block_height, block_hash, module FROM blocks
|
|
WHERE "block_height" = $1
|
|
`
|
|
|
|
func (q *Queries) GetBlock(ctx context.Context, blockHeight int64) (Block, error) {
|
|
row := q.db.QueryRow(ctx, getBlock, blockHeight)
|
|
var i Block
|
|
err := row.Scan(&i.BlockHeight, &i.BlockHash, &i.Module)
|
|
return i, err
|
|
}
|
|
|
|
const getLastProcessedBlock = `-- name: GetLastProcessedBlock :one
|
|
SELECT block_height, block_hash, module FROM blocks ORDER BY block_height DESC LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetLastProcessedBlock(ctx context.Context) (Block, error) {
|
|
row := q.db.QueryRow(ctx, getLastProcessedBlock)
|
|
var i Block
|
|
err := row.Scan(&i.BlockHeight, &i.BlockHash, &i.Module)
|
|
return i, err
|
|
}
|
|
|
|
const removeBlockFrom = `-- name: RemoveBlockFrom :execrows
|
|
DELETE FROM blocks
|
|
WHERE "block_height" >= $1
|
|
`
|
|
|
|
func (q *Queries) RemoveBlockFrom(ctx context.Context, fromBlock int64) (int64, error) {
|
|
result, err := q.db.Exec(ctx, removeBlockFrom, fromBlock)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return result.RowsAffected(), nil
|
|
}
|