-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
block.go
75 lines (65 loc) · 2.28 KB
/
block.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
68
69
70
71
72
73
74
75
package models
import (
"time"
)
type Block struct {
ID uint
TimeStamp time.Time
Height int64 `gorm:"uniqueIndex:chainheight"`
ChainID uint `gorm:"uniqueIndex:chainheight"`
Chain Chain
ProposerConsAddress Address
ProposerConsAddressID uint
TxIndexed bool
// TODO: Should block event indexing be split out or rolled up?
BlockEventsIndexed bool
}
// Used to keep track of BeginBlock and EndBlock events
type BlockLifecyclePosition int
const (
BeginBlockEvent BlockLifecyclePosition = iota
EndBlockEvent
)
type BlockEvent struct {
ID uint
// These fields uniquely identify every block event
// Index refers to the position of the event in the block event lifecycle array
// LifecyclePosition refers to whether the event is a BeginBlock or EndBlock event
Index uint64 `gorm:"uniqueIndex:eventBlockPositionIndex,priority:3"`
LifecyclePosition BlockLifecyclePosition `gorm:"uniqueIndex:eventBlockPositionIndex,priority:2"`
BlockID uint `gorm:"uniqueIndex:eventBlockPositionIndex,priority:1"`
Block Block
BlockEventTypeID uint
BlockEventType BlockEventType
}
type BlockEventType struct {
ID uint
Type string `gorm:"uniqueIndex"`
}
type BlockEventAttribute struct {
ID uint
BlockEvent BlockEvent
BlockEventID uint `gorm:"uniqueIndex:eventAttributeIndex,priority:1"`
Value string
Index uint64 `gorm:"uniqueIndex:eventAttributeIndex,priority:2"`
// Keys are limited to a smallish subset of string values set by the Cosmos SDK and external modules
// Save DB space by storing the key as a foreign key
BlockEventAttributeKeyID uint
BlockEventAttributeKey BlockEventAttributeKey
}
type BlockEventAttributeKey struct {
ID uint
Key string `gorm:"uniqueIndex"`
}
type FailedBlock struct {
ID uint
Height int64 `gorm:"uniqueIndex:failedchainheight"`
BlockchainID uint `gorm:"uniqueIndex:failedchainheight"`
Chain Chain `gorm:"foreignKey:BlockchainID"`
}
type FailedEventBlock struct {
ID uint
Height int64 `gorm:"uniqueIndex:failedchaineventheight"`
BlockchainID uint `gorm:"uniqueIndex:failedchaineventheight"`
Chain Chain `gorm:"foreignKey:BlockchainID"`
}