Skip to content

Commit

Permalink
address chris and bez comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnya97 committed Nov 3, 2018
1 parent 3664498 commit 94ba064
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ func MustSortJSON(toSortJSON []byte) []byte {
return js
}

// marshals int64 to a bigendian byte slice so it can be sorted
func Int64ToSortableBytes(i int64) []byte {
// Int64ToBigEndian - marshals int64 to a bigendian byte slice so it can be sorted
func Int64ToBigEndian(i int64) []byte {
b := make([]byte, 8)
binary.BigEndian.PutUint64(b, uint64(i))
return b
Expand Down
14 changes: 8 additions & 6 deletions x/gov/keeper_keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (

// Key for getting a the next available proposalID from the store
var (
KeyDelimiter = []byte("/")

KeyNextProposalID = []byte("newProposalID")
PrefixActiveProposalQueue = []byte("activeProposalQueue")
PrefixInactiveProposalQueue = []byte("inactiveProposalQueue")
Expand Down Expand Up @@ -47,31 +49,31 @@ func ActiveProposalQueueTimePrefix(endTime time.Time) []byte {
return bytes.Join([][]byte{
PrefixActiveProposalQueue,
sdk.FormatTimeBytes(endTime),
}, []byte("/"))
}, KeyDelimiter)
}

// Returns the key for a proposalID in the activeProposalQueue
func ActiveProposalQueueProposalKey(endTime time.Time, proposalID int64) []byte {
return bytes.Join([][]byte{
PrefixActiveProposalQueue,
sdk.FormatTimeBytes(endTime),
sdk.Int64ToSortableBytes(proposalID),
}, []byte("/"))
sdk.Int64ToBigEndian(proposalID),
}, KeyDelimiter)
}

// Returns the key for a proposalID in the activeProposalQueue
func InactiveProposalQueueTimePrefix(endTime time.Time) []byte {
return bytes.Join([][]byte{
PrefixInactiveProposalQueue,
sdk.FormatTimeBytes(endTime),
}, []byte("/"))
}, KeyDelimiter)
}

// Returns the key for a proposalID in the activeProposalQueue
func InactiveProposalQueueProposalKey(endTime time.Time, proposalID int64) []byte {
return bytes.Join([][]byte{
PrefixInactiveProposalQueue,
sdk.FormatTimeBytes(endTime),
sdk.Int64ToSortableBytes(proposalID),
}, []byte("/"))
sdk.Int64ToBigEndian(proposalID),
}, KeyDelimiter)
}

0 comments on commit 94ba064

Please sign in to comment.