-
Notifications
You must be signed in to change notification settings - Fork 44
/
state.go
67 lines (48 loc) · 2.07 KB
/
state.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
64
65
66
67
package verifreg
import (
"context"
"go.opencensus.io/tag"
"github.com/filecoin-project/lily/metrics"
"github.com/filecoin-project/lily/model"
)
const (
Added = "ADDED"
Removed = "REMOVED"
Modified = "MODIFIED"
)
type VerifiedRegistryVerifier struct {
Height int64 `pg:",pk,notnull,use_zero"`
StateRoot string `pg:",pk,notnull"`
Address string `pg:",pk,notnull"`
Event string `pg:",notnull,type:verified_registry_event_type"`
DataCap string `pg:",notnull,type:numeric"`
}
func (v *VerifiedRegistryVerifier) Persist(ctx context.Context, s model.StorageBatch, _ model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "verified_registry_verifier"))
return s.PersistModel(ctx, v)
}
type VerifiedRegistryVerifiersList []*VerifiedRegistryVerifier
func (v VerifiedRegistryVerifiersList) Persist(ctx context.Context, s model.StorageBatch, _ model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "verified_registry_verifier"))
return s.PersistModel(ctx, v)
}
type VerifiedRegistryVerifiedClient struct {
Height int64 `pg:",pk,notnull,use_zero"`
StateRoot string `pg:",pk,notnull"`
Address string `pg:",pk,notnull"`
Event string `pg:",notnull,type:verified_registry_event_type"`
DataCap string `pg:"type:numeric,notnull"`
}
func (v *VerifiedRegistryVerifiedClient) Persist(ctx context.Context, s model.StorageBatch, _ model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "verified_registry_verified_client"))
return s.PersistModel(ctx, v)
}
type VerifiedRegistryVerifiedClientsList []*VerifiedRegistryVerifiedClient
func (v VerifiedRegistryVerifiedClientsList) Persist(ctx context.Context, s model.StorageBatch, _ model.Version) error {
ctx, _ = tag.New(ctx, tag.Upsert(metrics.Table, "verified_registry_verified_client"))
return s.PersistModel(ctx, v)
}
var _ model.Persistable = (*VerifiedRegistryVerifier)(nil)
var _ model.Persistable = (*VerifiedRegistryVerifiersList)(nil)
var _ model.Persistable = (*VerifiedRegistryVerifiedClient)(nil)
var _ model.Persistable = (*VerifiedRegistryVerifiedClientsList)(nil)