Skip to content

Commit

Permalink
refactor(x/crosschain): remove unnecessary storage of transaction batch
Browse files Browse the repository at this point in the history
  • Loading branch information
fx0x55 committed Oct 24, 2024
1 parent bfb4a1a commit b491f84
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
13 changes: 4 additions & 9 deletions x/crosschain/keeper/bridge_call_out.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,23 +313,18 @@ func (k Keeper) CrosschainBaseCoin(
memo string,
originToken bool,
) error {
var cacheKey string
if fxTarget.IsIBC() {
sequence, err := k.IBCTransfer(ctx, from.Bytes(), receipt, amount, fxTarget.IBCChannel, memo)
if err != nil {
return err
}
cacheKey = types.NewIBCTransferKey(fxTarget.IBCChannel, sequence)
if originToken {
return k.erc20Keeper.SetCache(ctx, types.NewIBCTransferKey(fxTarget.IBCChannel, sequence), amount.Amount.Add(fee.Amount))
}
} else {
batchNonce, err := k.BuildOutgoingTxBatch(ctx, from, receipt, amount, fee)
if err != nil {
if _, err := k.BuildOutgoingTxBatch(ctx, from, receipt, amount, fee); err != nil {
return err
}
cacheKey = types.NewOriginTokenKey(fxTarget.GetModuleName(), batchNonce)
}

if originToken {
return k.erc20Keeper.SetCache(ctx, cacheKey, amount.Amount.Add(fee.Amount))
}
return nil
}
Expand Down
7 changes: 0 additions & 7 deletions x/crosschain/keeper/outgoing_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,6 @@ func (k Keeper) OutgoingTxBatchExecuted(ctx sdk.Context, tokenContract string, b
// Delete batch since it is finished
k.DeleteBatch(ctx, batch)
k.DeleteBatchConfirm(ctx, batch.BatchNonce, batch.TokenContract)
// Delete outgoing transfer relation
for _, tx := range batch.Transactions {
key := types.NewOriginTokenKey(k.moduleName, tx.Id)
if err = k.erc20Keeper.DeleteCache(ctx, key); err != nil {
return err
}
}
return nil
}

Expand Down

0 comments on commit b491f84

Please sign in to comment.