Skip to content

Commit

Permalink
Avoid propagating the CumulativeAttestedWeight if the commitment is n…
Browse files Browse the repository at this point in the history
…ot attested
  • Loading branch information
alexsporn committed Apr 23, 2024
1 parent 7c134ce commit cf0062b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/protocol/commitment.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,13 @@ func (c *Commitment) deriveChain(parent *Commitment) func() {
// deriveCumulativeAttestedWeight derives the CumulativeAttestedWeight of this Commitment which is the sum of the
// parent's CumulativeAttestedWeight and the AttestedWeight of this Commitment.
func (c *Commitment) deriveCumulativeAttestedWeight(parent *Commitment) func() {
return c.CumulativeAttestedWeight.DeriveValueFrom(reactive.NewDerivedVariable2(func(_ uint64, parentCumulativeAttestedWeight uint64, attestedWeight uint64) uint64 {
return c.CumulativeAttestedWeight.DeriveValueFrom(reactive.NewDerivedVariable3(func(currentCumulativeAttestedWeight uint64, parentCumulativeAttestedWeight uint64, attestedWeight uint64, isAttested bool) uint64 {
if !isAttested {
return currentCumulativeAttestedWeight
}

return parentCumulativeAttestedWeight + attestedWeight
}, parent.CumulativeAttestedWeight, c.AttestedWeight))
}, parent.CumulativeAttestedWeight, c.AttestedWeight, c.IsAttested))
}

// deriveCumulativeVerifiedWeight derives the CumulativeVerifiedWeight of this Commitment which is the same as the
Expand Down

0 comments on commit cf0062b

Please sign in to comment.