github.com/fibonacci-chain/fbc@v0.0.0-20231124064014-c7636198c1e9/libs/cosmos-sdk/baseapp/baseapp_mode_deliver.go (about) 1 package baseapp 2 3 import ( 4 sdk "github.com/fibonacci-chain/fbc/libs/cosmos-sdk/types" 5 ) 6 7 func (m *modeHandlerDeliver) handleRunMsg(info *runTxInfo) (err error) { 8 app := m.app 9 mode := m.mode 10 if cms, ok := info.GetCacheMultiStore(); ok { 11 info.runMsgCtx, info.msCache = info.ctx, cms 12 info.runMsgCtx.SetMultiStore(info.msCache) 13 } else { 14 info.runMsgCtx, info.msCache = app.cacheTxContext(info.ctx, info.txBytes) 15 } 16 17 info.ctx.Cache().Write(false) 18 info.result, err = app.runMsgs(info.runMsgCtx, info.tx.GetMsgs(), mode) 19 if err == nil { 20 info.msCache.Write() 21 info.ctx.Cache().Write(true) 22 info.PutCacheMultiStore(info.msCache) 23 info.msCache = nil 24 } 25 26 info.runMsgFinished = true 27 err = m.checkHigherThanMercury(err, info) 28 return 29 } 30 31 type CacheTxContextFunc func(ctx sdk.Context, txBytes []byte) (sdk.Context, sdk.CacheMultiStore) 32 33 // this handleGasRefund func is also called by modeHandlerTrace.handleDeferRefund 34 // in this func, edit any member in BaseApp is prohibited 35 func handleGasRefund(info *runTxInfo, cacheTxCtxFunc CacheTxContextFunc, gasRefundHandler sdk.GasRefundHandler) sdk.DecCoins { 36 var gasRefundCtx sdk.Context 37 info.ctx.Cache().Write(false) 38 if cms, ok := info.GetCacheMultiStore(); ok { 39 gasRefundCtx, info.msCache = info.ctx, cms 40 gasRefundCtx.SetMultiStore(info.msCache) 41 } else { 42 gasRefundCtx, info.msCache = cacheTxCtxFunc(info.ctx, info.txBytes) 43 } 44 45 refund, err := gasRefundHandler(gasRefundCtx, info.tx) 46 if err != nil { 47 panic(err) 48 } 49 info.msCache.Write() 50 info.PutCacheMultiStore(info.msCache) 51 info.msCache = nil 52 info.ctx.Cache().Write(true) 53 return refund 54 } 55 func (m *modeHandlerDeliver) handleDeferRefund(info *runTxInfo) { 56 if m.app.GasRefundHandler == nil { 57 return 58 } 59 refund := handleGasRefund(info, m.app.cacheTxContext, m.app.GasRefundHandler) 60 m.app.UpdateFeeCollector(refund, false) 61 if info.ctx.GetFeeSplitInfo().HasFee { 62 m.app.FeeSplitCollector = append(m.app.FeeSplitCollector, info.ctx.GetFeeSplitInfo()) 63 } 64 65 } 66 67 func (m *modeHandlerDeliver) handleDeferGasConsumed(info *runTxInfo) { 68 m.setGasConsumed(info) 69 }