Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose canonical warp formatting function #3049

Merged
merged 1 commit into from
May 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading