-
Notifications
You must be signed in to change notification settings - Fork 11
/
blob_log.go
63 lines (52 loc) 路 2.5 KB
/
blob_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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// SPDX-FileCopyrightText: 2024 PK Lab AG <contact@pklab.io>
// SPDX-License-Identifier: MIT
package storage
import (
"context"
"io"
"time"
"github.com/celenium-io/celestia-indexer/pkg/types"
"github.com/dipdup-net/indexer-sdk/pkg/storage"
sdk "github.com/dipdup-net/indexer-sdk/pkg/storage"
"github.com/shopspring/decimal"
"github.com/uptrace/bun"
)
type BlobLogFilters struct {
Limit int
Offset int
Sort sdk.SortOrder
SortBy string
}
//go:generate mockgen -source=$GOFILE -destination=mock/$GOFILE -package=mock -typed
type IBlobLog interface {
storage.Table[*BlobLog]
ByNamespace(ctx context.Context, nsId uint64, fltrs BlobLogFilters) ([]BlobLog, error)
ByProviders(ctx context.Context, providers []RollupProvider, fltrs BlobLogFilters) ([]BlobLog, error)
BySigner(ctx context.Context, signerId uint64, fltrs BlobLogFilters) ([]BlobLog, error)
ByTxId(ctx context.Context, txId uint64, fltrs BlobLogFilters) ([]BlobLog, error)
ByHeight(ctx context.Context, height types.Level, fltrs BlobLogFilters) ([]BlobLog, error)
CountByTxId(ctx context.Context, txId uint64) (int, error)
CountByHeight(ctx context.Context, height types.Level) (int, error)
ExportByProviders(ctx context.Context, providers []RollupProvider, from, to time.Time, stream io.Writer) (err error)
}
type BlobLog struct {
bun.BaseModel `bun:"blob_log" comment:"Table with flatted blob entities."`
Id uint64 `bun:"id,pk,autoincrement" comment:"Unique internal identity"`
Time time.Time `bun:"time,notnull,pk" comment:"Message time"`
Height types.Level `bun:"height" comment:"Message block height"`
Size int64 `bun:"size" comment:"Blob size"`
Commitment string `bun:"commitment" comment:"Blob commitment"`
ContentType string `bun:"content_type" comment:"Blob content type"`
Fee decimal.Decimal `bun:"fee,type:numeric" comment:"Fee per blob"`
SignerId uint64 `bun:"signer_id" comment:"Blob signer identity"`
NamespaceId uint64 `bun:"namespace_id" comment:"Namespace internal id"`
MsgId uint64 `bun:"msg_id" comment:"Message id"`
TxId uint64 `bun:"tx_id" comment:"Transaction id"`
Message *Message `bun:"rel:belongs-to,join:msg_id=id"`
Namespace *Namespace `bun:"rel:belongs-to,join:namespace_id=id"`
Tx *Tx `bun:"rel:belongs-to,join:tx_id=id"`
Signer *Address `bun:"rel:belongs-to,join:signer_id=id"`
}
func (BlobLog) TableName() string {
return "blob_log"
}