@@ -243,6 +243,10 @@ func (c *Commitment) initDerivedProperties() (shutdown func()) {
243
243
c .IsVerified .InheritFrom (c .IsRoot ),
244
244
c .IsSolid .InheritFrom (c .IsRoot ),
245
245
246
+ c .IsRoot .OnTrigger (func () {
247
+ c .CumulativeAttestedWeight .Set (c .Commitment .CumulativeWeight ())
248
+ }),
249
+
246
250
// mark commitments that are marked as verified as attested and synced
247
251
c .IsAttested .InheritFrom (c .IsVerified ),
248
252
c .IsSynced .InheritFrom (c .IsVerified ),
@@ -336,9 +340,13 @@ func (c *Commitment) deriveChain(parent *Commitment) func() {
336
340
// deriveCumulativeAttestedWeight derives the CumulativeAttestedWeight of this Commitment which is the sum of the
337
341
// parent's CumulativeAttestedWeight and the AttestedWeight of this Commitment.
338
342
func (c * Commitment ) deriveCumulativeAttestedWeight (parent * Commitment ) func () {
339
- return c .CumulativeAttestedWeight .DeriveValueFrom (reactive .NewDerivedVariable2 (func (_ uint64 , parentCumulativeAttestedWeight uint64 , attestedWeight uint64 ) uint64 {
343
+ return c .CumulativeAttestedWeight .DeriveValueFrom (reactive .NewDerivedVariable3 (func (currentCumulativeAttestedWeight uint64 , parentCumulativeAttestedWeight uint64 , attestedWeight uint64 , isAttested bool ) uint64 {
344
+ if ! isAttested {
345
+ return currentCumulativeAttestedWeight
346
+ }
347
+
340
348
return parentCumulativeAttestedWeight + attestedWeight
341
- }, parent .CumulativeAttestedWeight , c .AttestedWeight ))
349
+ }, parent .CumulativeAttestedWeight , c .AttestedWeight , c . IsAttested ))
342
350
}
343
351
344
352
// deriveCumulativeVerifiedWeight derives the CumulativeVerifiedWeight of this Commitment which is the same as the
0 commit comments