diff --git a/types/utils.go b/types/utils.go index db6851f80d8f..289aef472f43 100644 --- a/types/utils.go +++ b/types/utils.go @@ -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 diff --git a/x/gov/keeper_keys.go b/x/gov/keeper_keys.go index 57f38fdd6b29..b171961f99c0 100644 --- a/x/gov/keeper_keys.go +++ b/x/gov/keeper_keys.go @@ -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") @@ -47,7 +49,7 @@ 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 @@ -55,8 +57,8 @@ 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 @@ -64,7 +66,7 @@ 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 @@ -72,6 +74,6 @@ func InactiveProposalQueueProposalKey(endTime time.Time, proposalID int64) []byt return bytes.Join([][]byte{ PrefixInactiveProposalQueue, sdk.FormatTimeBytes(endTime), - sdk.Int64ToSortableBytes(proposalID), - }, []byte("/")) + sdk.Int64ToBigEndian(proposalID), + }, KeyDelimiter) }