Skip to content

Commit

Permalink
[CT-727] avoid state reads when sending updates (#1261)
Browse files Browse the repository at this point in the history
  • Loading branch information
jayy04 committed Mar 28, 2024
1 parent 8e80f0b commit 54c2f01
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions protocol/x/clob/keeper/order_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/dydxprotocol/v4-chain/protocol/indexer/off_chain_updates"
"github.com/dydxprotocol/v4-chain/protocol/lib"
"github.com/dydxprotocol/v4-chain/protocol/x/clob/types"

Expand Down Expand Up @@ -271,8 +272,13 @@ func (k Keeper) PruneStateFillAmountsForShortTermOrders(
allUpdates := types.NewOffchainUpdates()
for _, orderId := range prunedOrderIds {
if _, exists := k.MemClob.GetOrder(ctx, orderId); exists {
orderbookUpdate := k.MemClob.GetOrderbookUpdatesForOrderUpdate(ctx, orderId)
allUpdates.Append(orderbookUpdate)
if message, success := off_chain_updates.CreateOrderUpdateMessage(
ctx,
orderId,
0, // Total filled quantums is zero because it's been pruned from state.
); success {
allUpdates.AddUpdateMessage(orderId, message)
}
}
}
k.SendOrderbookUpdates(ctx, allUpdates, false)
Expand Down

0 comments on commit 54c2f01

Please sign in to comment.