-
Notifications
You must be signed in to change notification settings - Fork 11
/
address.go
49 lines (37 loc) 路 1.4 KB
/
address.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
44
45
46
47
48
49
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"github.com/celenium-io/celestia-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/uptrace/bun"
)
type AddressListFilter struct {
Limit int
Offset int
Sort storage.SortOrder
}
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IAddress interface {
storage.Table[*Address]
ByHash(ctx context.Context, hash []byte) (Address, error)
ListWithBalance(ctx context.Context, filters AddressListFilter) ([]Address, error)
}
// Address -
type Address struct {
bun.BaseModel `bun:"address" comment:"Table with celestia addresses."`
Id uint64 `bun:"id,pk,notnull,autoincrement" comment:"Unique internal identity"`
Height types.Level `bun:"height" comment:"Block number of the first address occurrence."`
LastHeight types.Level `bun:"last_height" comment:"Block number of the last address occurrence."`
Hash []byte `bun:"hash" comment:"Address hash."`
Address string `bun:"address,unique:address_idx" comment:"Human-readable address."`
Balance Balance `bun:"rel:has-one,join:id=id"`
}
// TableName -
func (Address) TableName() string {
return "address"
}
func (address Address) String() string {
return address.Address
}