@@ -49,21 +49,21 @@ type TipMetadata struct {
49
49
// that is connected to the tips.
50
50
isReferencedByTips reactive.Variable [bool ]
51
51
52
- // isLatestValidatorBlock is true if the block is the latest block of a validator.
53
- isLatestValidatorBlock reactive.Variable [bool ]
52
+ // isLatestValidationBlock is true if the block is the latest block of a validator.
53
+ isLatestValidationBlock reactive.Variable [bool ]
54
54
55
- // referencesLatestValidatorBlock is true if the block is the latest validator block or has parents that reference
55
+ // referencesLatestValidationBlock is true if the block is the latest validator block or has parents that reference
56
56
// the latest validator block.
57
- referencesLatestValidatorBlock reactive.Variable [bool ]
57
+ referencesLatestValidationBlock reactive.Variable [bool ]
58
58
59
59
// isStrongTip is true if the block is a strong tip pool member and is not strongly referenced by other tips.
60
60
isStrongTip reactive.Variable [bool ]
61
61
62
62
// isWeakTip is true if the block is a weak tip pool member and is not referenced by other tips.
63
63
isWeakTip reactive.Variable [bool ]
64
64
65
- // isValidatorTip is true if the block is a strong tip and references the latest validator block.
66
- isValidatorTip reactive.Variable [bool ]
65
+ // isValidationTip is true if the block is a strong tip and references the latest validator block.
66
+ isValidationTip reactive.Variable [bool ]
67
67
68
68
// isMarkedOrphaned is true if the liveness threshold has been reached and the block was not accepted.
69
69
isMarkedOrphaned reactive.Variable [bool ]
@@ -97,28 +97,28 @@ type TipMetadata struct {
97
97
// weaklyOrphanedWeakParents holds the number of weak parents that are weakly orphaned.
98
98
weaklyOrphanedWeakParents reactive.Counter [bool ]
99
99
100
- // parentsReferencingLatestValidatorBlock holds the number of parents that reference the latest validator block.
101
- parentsReferencingLatestValidatorBlock reactive.Counter [bool ]
100
+ // parentsReferencingLatestValidationBlock holds the number of parents that reference the latest validator block.
101
+ parentsReferencingLatestValidationBlock reactive.Counter [bool ]
102
102
}
103
103
104
104
// NewBlockMetadata creates a new TipMetadata instance.
105
105
func NewBlockMetadata (block * blocks.Block ) * TipMetadata {
106
106
t := & TipMetadata {
107
- block : block ,
108
- tipPool : reactive.NewVariable [tipmanager.TipPool ](tipmanager .TipPool .Max ),
109
- livenessThresholdReached : reactive .NewEvent (),
110
- evicted : reactive .NewEvent (),
111
- isLatestValidatorBlock : reactive .NewVariable [bool ](),
112
- stronglyConnectedStrongChildren : reactive .NewCounter [bool ](),
113
- connectedWeakChildren : reactive .NewCounter [bool ](),
114
- stronglyOrphanedStrongParents : reactive .NewCounter [bool ](),
115
- weaklyOrphanedWeakParents : reactive .NewCounter [bool ](),
116
- parentsReferencingLatestValidatorBlock : reactive .NewCounter [bool ](),
107
+ block : block ,
108
+ tipPool : reactive.NewVariable [tipmanager.TipPool ](tipmanager .TipPool .Max ),
109
+ livenessThresholdReached : reactive .NewEvent (),
110
+ evicted : reactive .NewEvent (),
111
+ isLatestValidationBlock : reactive .NewVariable [bool ](),
112
+ stronglyConnectedStrongChildren : reactive .NewCounter [bool ](),
113
+ connectedWeakChildren : reactive .NewCounter [bool ](),
114
+ stronglyOrphanedStrongParents : reactive .NewCounter [bool ](),
115
+ weaklyOrphanedWeakParents : reactive .NewCounter [bool ](),
116
+ parentsReferencingLatestValidationBlock : reactive .NewCounter [bool ](),
117
117
}
118
118
119
- t .referencesLatestValidatorBlock = reactive .NewDerivedVariable2 (func (_ bool , isLatestValidatorBlock bool , parentsReferencingLatestValidatorBlock int ) bool {
120
- return isLatestValidatorBlock || parentsReferencingLatestValidatorBlock > 0
121
- }, t .isLatestValidatorBlock , t .parentsReferencingLatestValidatorBlock )
119
+ t .referencesLatestValidationBlock = reactive .NewDerivedVariable2 (func (_ bool , isLatestValidationBlock bool , parentsReferencingLatestValidationBlock int ) bool {
120
+ return isLatestValidationBlock || parentsReferencingLatestValidationBlock > 0
121
+ }, t .isLatestValidationBlock , t .parentsReferencingLatestValidationBlock )
122
122
123
123
t .isMarkedOrphaned = reactive .NewDerivedVariable2 [bool , bool ](func (_ bool , isLivenessThresholdReached bool , isAccepted bool ) bool {
124
124
return isLivenessThresholdReached && ! isAccepted
@@ -180,9 +180,9 @@ func NewBlockMetadata(block *blocks.Block) *TipMetadata {
180
180
return isWeakTipPoolMember && ! isReferencedByTips
181
181
}, t .isWeakTipPoolMember , t .isReferencedByTips )
182
182
183
- t .isValidatorTip = reactive .NewDerivedVariable2 (func (_ bool , isStrongTip bool , referencesLatestValidatorBlock bool ) bool {
184
- return isStrongTip && referencesLatestValidatorBlock
185
- }, t .isStrongTip , t .referencesLatestValidatorBlock )
183
+ t .isValidationTip = reactive .NewDerivedVariable2 (func (_ bool , isStrongTip bool , referencesLatestValidationBlock bool ) bool {
184
+ return isStrongTip && referencesLatestValidationBlock
185
+ }, t .isStrongTip , t .referencesLatestValidationBlock )
186
186
187
187
return t
188
188
}
@@ -227,25 +227,25 @@ func (t *TipMetadata) Evicted() reactive.Event {
227
227
return t .evicted
228
228
}
229
229
230
- // registerAsLatestValidatorBlock registers the TipMetadata as the latest validator block if it is newer than the
231
- // currently registered block and sets the isLatestValidatorBlock variable accordingly. The function returns true if the
230
+ // registerAsLatestValidationBlock registers the TipMetadata as the latest validation block if it is newer than the
231
+ // currently registered block and sets the isLatestValidationBlock variable accordingly. The function returns true if the
232
232
// operation was successful.
233
- func (t * TipMetadata ) registerAsLatestValidatorBlock ( latestValidatorBlock reactive.Variable [* TipMetadata ]) (registered bool ) {
234
- latestValidatorBlock .Compute (func (currentLatestValidatorBlock * TipMetadata ) * TipMetadata {
235
- registered = currentLatestValidatorBlock == nil || currentLatestValidatorBlock .block .IssuingTime ().Before (t .block .IssuingTime ())
233
+ func (t * TipMetadata ) registerAsLatestValidationBlock ( latestValidationBlock reactive.Variable [* TipMetadata ]) (registered bool ) {
234
+ latestValidationBlock .Compute (func (currentLatestValidationBlock * TipMetadata ) * TipMetadata {
235
+ registered = currentLatestValidationBlock == nil || currentLatestValidationBlock .block .IssuingTime ().Before (t .block .IssuingTime ())
236
236
237
- return lo .Cond (registered , t , currentLatestValidatorBlock )
237
+ return lo .Cond (registered , t , currentLatestValidationBlock )
238
238
})
239
239
240
240
if registered {
241
- t .isLatestValidatorBlock .Set (true )
241
+ t .isLatestValidationBlock .Set (true )
242
242
243
- // Once the latestValidatorBlock is updated again (by another block), we need to reset the isLatestValidatorBlock
243
+ // Once the latestValidationBlock is updated again (by another block), we need to reset the isLatestValidationBlock
244
244
// variable.
245
- latestValidatorBlock .OnUpdateOnce (func (_ * TipMetadata , _ * TipMetadata ) {
246
- t .isLatestValidatorBlock .Set (false )
247
- }, func (_ * TipMetadata , latestValidatorBlock * TipMetadata ) bool {
248
- return latestValidatorBlock != t
245
+ latestValidationBlock .OnUpdateOnce (func (_ * TipMetadata , _ * TipMetadata ) {
246
+ t .isLatestValidationBlock .Set (false )
247
+ }, func (_ * TipMetadata , latestValidationBlock * TipMetadata ) bool {
248
+ return latestValidationBlock != t
249
249
})
250
250
}
251
251
@@ -255,7 +255,7 @@ func (t *TipMetadata) registerAsLatestValidatorBlock(latestValidatorBlock reacti
255
255
// connectStrongParent sets up the parent and children related properties for a strong parent.
256
256
func (t * TipMetadata ) connectStrongParent (strongParent * TipMetadata ) {
257
257
t .stronglyOrphanedStrongParents .Monitor (strongParent .isStronglyOrphaned )
258
- t .parentsReferencingLatestValidatorBlock .Monitor (strongParent .referencesLatestValidatorBlock )
258
+ t .parentsReferencingLatestValidationBlock .Monitor (strongParent .referencesLatestValidationBlock )
259
259
260
260
// unsubscribe when the parent is evicted, since we otherwise continue to hold a reference to it.
261
261
unsubscribe := strongParent .stronglyConnectedStrongChildren .Monitor (t .isStronglyConnectedToTips )
0 commit comments