-
Notifications
You must be signed in to change notification settings - Fork 12
/
staking_log.go
43 lines (34 loc) · 1.69 KB
/
staking_log.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
37
38
39
40
41
42
43
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"time"
"github.com/celenium-io/celestia-indexer/internal/storage/types"
pkgTypes "github.com/celenium-io/celestia-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/shopspring/decimal"
"github.com/uptrace/bun"
)
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IStakingLog interface {
storage.Table[*StakingLog]
ByValidator(ctx context.Context, validatorId uint64, limit, offset int) ([]StakingLog, error)
}
// Delegation -
type StakingLog struct {
bun.BaseModel `bun:"staking_log" comment:"Table with staking events log"`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal id"`
Time time.Time `bun:"time,pk,notnull" comment:"The time of block" stats:"func:min max,filterable"`
Height pkgTypes.Level `bun:"height,notnull" comment:"The number (height) of this block" stats:"func:min max,filterable"`
AddressId *uint64 `bun:"address_id" comment:"Internal address id"`
ValidatorId uint64 `bun:"validator_id" comment:"Internal validator id"`
Change decimal.Decimal `bun:"change,type:numeric" comment:"Change amount"`
Type types.StakingLogType `bun:"type,type:staking_log_type" comment:"Staking log type"`
Address *Address `bun:"rel:belongs-to,join:address_id=id"`
Validator *Validator `bun:"rel:belongs-to,join:validator_id=id"`
}
// TableName -
func (StakingLog) TableName() string {
return "staking_log"
}