-
Notifications
You must be signed in to change notification settings - Fork 11
/
block_signature.go
36 lines (30 loc) 路 976 Bytes
/
block_signature.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package postgres
import (
"context"
"github.com/celenium-io/celestia-indexer/internal/storage"
"github.com/celenium-io/celestia-indexer/pkg/types"
"github.com/dipdup-net/go-lib/database"
"github.com/dipdup-net/indexer-sdk/pkg/storage/postgres"
)
// BlockSignature -
type BlockSignature struct {
*postgres.Table[*storage.BlockSignature]
}
// NewBlockSignature -
func NewBlockSignature(db *database.Bun) *BlockSignature {
return &BlockSignature{
Table: postgres.NewTable[*storage.BlockSignature](db),
}
}
func (bs *BlockSignature) LevelsByValidator(ctx context.Context, validatorId uint64, startHeight types.Level) (levels []types.Level, err error) {
err = bs.DB().NewSelect().
Model((*storage.BlockSignature)(nil)).
Column("height").
Where("validator_id = ?", validatorId).
Where("height > ?", startHeight).
Order("id desc").
Scan(ctx, &levels)
return
}