@@ -49,21 +49,21 @@ type TipMetadata struct {
4949 // that is connected to the tips.
5050 isReferencedByTips reactive.Variable [bool ]
5151
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 ]
5454
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
5656 // the latest validator block.
57- referencesLatestValidatorBlock reactive.Variable [bool ]
57+ referencesLatestValidationBlock reactive.Variable [bool ]
5858
5959 // isStrongTip is true if the block is a strong tip pool member and is not strongly referenced by other tips.
6060 isStrongTip reactive.Variable [bool ]
6161
6262 // isWeakTip is true if the block is a weak tip pool member and is not referenced by other tips.
6363 isWeakTip reactive.Variable [bool ]
6464
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 ]
6767
6868 // isMarkedOrphaned is true if the liveness threshold has been reached and the block was not accepted.
6969 isMarkedOrphaned reactive.Variable [bool ]
@@ -97,28 +97,28 @@ type TipMetadata struct {
9797 // weaklyOrphanedWeakParents holds the number of weak parents that are weakly orphaned.
9898 weaklyOrphanedWeakParents reactive.Counter [bool ]
9999
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 ]
102102}
103103
104104// NewBlockMetadata creates a new TipMetadata instance.
105105func NewBlockMetadata (block * blocks.Block ) * TipMetadata {
106106 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 ](),
117117 }
118118
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 )
122122
123123 t .isMarkedOrphaned = reactive .NewDerivedVariable2 [bool , bool ](func (_ bool , isLivenessThresholdReached bool , isAccepted bool ) bool {
124124 return isLivenessThresholdReached && ! isAccepted
@@ -180,9 +180,9 @@ func NewBlockMetadata(block *blocks.Block) *TipMetadata {
180180 return isWeakTipPoolMember && ! isReferencedByTips
181181 }, t .isWeakTipPoolMember , t .isReferencedByTips )
182182
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 )
186186
187187 return t
188188}
@@ -227,25 +227,25 @@ func (t *TipMetadata) Evicted() reactive.Event {
227227 return t .evicted
228228}
229229
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
232232// 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 ())
236236
237- return lo .Cond (registered , t , currentLatestValidatorBlock )
237+ return lo .Cond (registered , t , currentLatestValidationBlock )
238238 })
239239
240240 if registered {
241- t .isLatestValidatorBlock .Set (true )
241+ t .isLatestValidationBlock .Set (true )
242242
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
244244 // 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
249249 })
250250 }
251251
@@ -255,7 +255,7 @@ func (t *TipMetadata) registerAsLatestValidatorBlock(latestValidatorBlock reacti
255255// connectStrongParent sets up the parent and children related properties for a strong parent.
256256func (t * TipMetadata ) connectStrongParent (strongParent * TipMetadata ) {
257257 t .stronglyOrphanedStrongParents .Monitor (strongParent .isStronglyOrphaned )
258- t .parentsReferencingLatestValidatorBlock .Monitor (strongParent .referencesLatestValidatorBlock )
258+ t .parentsReferencingLatestValidationBlock .Monitor (strongParent .referencesLatestValidationBlock )
259259
260260 // unsubscribe when the parent is evicted, since we otherwise continue to hold a reference to it.
261261 unsubscribe := strongParent .stronglyConnectedStrongChildren .Monitor (t .isStronglyConnectedToTips )
0 commit comments