From 6d4a4cf0292161cad601762d0b7b3f0895a01478 Mon Sep 17 00:00:00 2001 From: Tanmay Date: Thu, 28 Nov 2024 14:14:38 -0500 Subject: [PATCH] update comments for SetCctxAndNonceToCctxAndInboundHashToCctx --- x/crosschain/keeper/cctx.go | 9 +++++---- x/crosschain/keeper/cctx_test.go | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/x/crosschain/keeper/cctx.go b/x/crosschain/keeper/cctx.go index 32d002bc7d..59e5698af7 100644 --- a/x/crosschain/keeper/cctx.go +++ b/x/crosschain/keeper/cctx.go @@ -21,8 +21,9 @@ import ( // 2. Set the cctx in the store -// 3. set the mapping inboundHash -> cctxIndex +// 3. Update the mapping inboundHash -> cctxIndex // A new value is added to the mapping when a single inbound hash is connected to multiple cctx indexes +// If the inbound hash to cctx mapping does not exist, a new mapping is created and the cctx index is added to the list of cctx indexes // 4. update the zeta accounting // Zeta-accounting is updated aborted cctxs of cointtype zeta.When a cctx is aborted it means that `GetAbortedAmount` @@ -33,7 +34,7 @@ func (k Keeper) SetCctxAndNonceToCctxAndInboundHashToCctx( cctx types.CrossChainTx, tssPubkey string, ) { - k.UpdateNonceToCCTX(ctx, cctx, tssPubkey) + k.SetNonceToCCTXMapping(ctx, cctx, tssPubkey) k.SetCrossChainTx(ctx, cctx) k.UpdateInboundHashToCCTX(ctx, cctx) k.UpdateZetaAccounting(ctx, cctx) @@ -69,8 +70,8 @@ func (k Keeper) UpdateZetaAccounting( } } -// UpdateNonceToCCTX updates the mapping between a nonce and a cctx index if the cctx is in a PendingOutbound or PendingRevert state -func (k Keeper) UpdateNonceToCCTX( +// SetNonceToCCTXMapping updates the mapping between a nonce and a cctx index if the cctx is in a PendingOutbound or PendingRevert state +func (k Keeper) SetNonceToCCTXMapping( ctx sdk.Context, cctx types.CrossChainTx, tssPubkey string, diff --git a/x/crosschain/keeper/cctx_test.go b/x/crosschain/keeper/cctx_test.go index 22f3c61049..9389c8307e 100644 --- a/x/crosschain/keeper/cctx_test.go +++ b/x/crosschain/keeper/cctx_test.go @@ -468,7 +468,7 @@ func TestKeeper_UpdateNonceToCCTX(t *testing.T) { tssPubkey := "test-tss-pubkey" // Act - k.UpdateNonceToCCTX(ctx, cctx, tssPubkey) + k.SetNonceToCCTXMapping(ctx, cctx, tssPubkey) // Assert nonceToCctx, found := k.GetObserverKeeper().GetNonceToCctx(ctx, tssPubkey, chainID, int64(nonce)) @@ -491,7 +491,7 @@ func TestKeeper_UpdateNonceToCCTX(t *testing.T) { tssPubkey := "test-tss-pubkey" // Act - k.UpdateNonceToCCTX(ctx, cctx, tssPubkey) + k.SetNonceToCCTXMapping(ctx, cctx, tssPubkey) // Assert nonceToCctx, found := k.GetObserverKeeper().GetNonceToCctx(ctx, tssPubkey, chainID, int64(nonce)) @@ -514,7 +514,7 @@ func TestKeeper_UpdateNonceToCCTX(t *testing.T) { tssPubkey := "test-tss-pubkey" // Act - k.UpdateNonceToCCTX(ctx, cctx, tssPubkey) + k.SetNonceToCCTXMapping(ctx, cctx, tssPubkey) // Assert _, found := k.GetObserverKeeper().GetNonceToCctx(ctx, tssPubkey, chainID, int64(nonce))