From e56f8c0bbb7e60cde633bf303b8fedc33d704ad9 Mon Sep 17 00:00:00 2001 From: Sammy Date: Mon, 2 Dec 2024 14:08:09 -0500 Subject: [PATCH] refactor(nexus): rename nextID to currIDAndIncr and update the doc (#2214) --- x/nexus/keeper/general_message.go | 2 +- x/nexus/keeper/msg_id_generator.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/x/nexus/keeper/general_message.go b/x/nexus/keeper/general_message.go index d61548dee..69f1e1f76 100644 --- a/x/nexus/keeper/general_message.go +++ b/x/nexus/keeper/general_message.go @@ -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 } diff --git a/x/nexus/keeper/msg_id_generator.go b/x/nexus/keeper/msg_id_generator.go index 935f79a44..315a2b022 100644 --- a/x/nexus/keeper/msg_id_generator.go +++ b/x/nexus/keeper/msg_id_generator.go @@ -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) }