Skip to content

Commit

Permalink
nit add invaraint
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenButtolph committed Jul 24, 2023
1 parent 69b04c4 commit 1637246
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions vms/platformvm/state/disk_staker_diff_iterator.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,16 @@ func parseBLSKey(key []byte) (uint64, ids.NodeID, error) {

// Note: [height] is encoded as a bit flipped big endian number so that
// iterating lexicographically results in iterating in decreasing heights.
//
// Invariant: [key] has sufficient length
func packIterableHeight(key []byte, height uint64) {
binary.BigEndian.PutUint64(key, ^height)
}

// Because we bit flip the height when constructing the key, we must remember to
// bip flip again here.
//
// Invariant: [key] has sufficient length
func unpackIterableHeight(key []byte) uint64 {
return ^binary.BigEndian.Uint64(key)
}

0 comments on commit 1637246

Please sign in to comment.