Skip to content

Commit

Permalink
Expose canonical warp formatting function (#3049)
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph authored May 24, 2024
1 parent 944d3db commit 54c4b53
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions vms/platformvm/warp/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,17 @@ func GetCanonicalValidatorSet(
return nil, 0, err
}

// Convert the validator set into the canonical ordering.
return FlattenValidatorSet(vdrSet)
}

// FlattenValidatorSet converts the provided [vdrSet] into a canonical ordering.
// Also returns the total weight of the validator set.
func FlattenValidatorSet(vdrSet map[ids.NodeID]*validators.GetValidatorOutput) ([]*Validator, uint64, error) {
var (
vdrs = make(map[string]*Validator, len(vdrSet))
totalWeight uint64
err error
)
for _, vdr := range vdrSet {
totalWeight, err = math.Add64(totalWeight, vdr.Weight)
Expand Down

0 comments on commit 54c4b53

Please sign in to comment.