Skip to content

Commit

Permalink
refactor(nexus): rename nextID to currIDAndIncr and update the doc (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
fish-sammy authored Dec 2, 2024
1 parent 3cb1ee8 commit e56f8c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion x/nexus/keeper/general_message.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func getProcessingMessageKey(destinationChain exported.ChainName, id string) key
// GenerateMessageID generates a unique general message ID, and returns the message ID, current transacation ID and a unique integer nonce
// The message ID is just a concatenation of the transaction ID and the nonce
func (k Keeper) GenerateMessageID(ctx sdk.Context) (string, []byte, uint64) {
hash, nonce := k.nextID(ctx)
hash, nonce := k.currIDAndIncr(ctx)

return fmt.Sprintf("0x%s-%d", hex.EncodeToString(hash[:]), nonce), hash[:], nonce
}
Expand Down
6 changes: 3 additions & 3 deletions x/nexus/keeper/msg_id_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ func (k Keeper) IncrID(ctx sdk.Context) {
utils.NewCounter[uint64](messageNonceKey, k.getStore(ctx)).Incr(ctx)
}

// nextID returns the transaction hash of the current transaction and the incremented nonce
func (k Keeper) nextID(ctx sdk.Context) ([32]byte, uint64) {
// currIDAndIncr returns the current transaction hash and nonce, and increments the nonce
func (k Keeper) currIDAndIncr(ctx sdk.Context) ([32]byte, uint64) {
return getTxHash(ctx), utils.NewCounter[uint64](messageNonceKey, k.getStore(ctx)).Incr(ctx)
}

// CurrID returns the current transaction hash and index
// CurrID returns the current transaction hash and nonce
func (k Keeper) CurrID(ctx sdk.Context) ([32]byte, uint64) {
return getTxHash(ctx), utils.NewCounter[uint64](messageNonceKey, k.getStore(ctx)).Curr(ctx)
}

0 comments on commit e56f8c0

Please sign in to comment.