(goCtx context.Context, msg *types.MsgModifyPmtpRates)
| 212 | } |
| 213 | |
| 214 | func (k msgServer) ModifyPmtpRates(goCtx context.Context, msg *types.MsgModifyPmtpRates) (*types.MsgModifyPmtpRatesResponse, error) { |
| 215 | ctx := sdk.UnwrapSDKContext(goCtx) |
| 216 | response := &types.MsgModifyPmtpRatesResponse{} |
| 217 | signer, err := sdk.AccAddressFromBech32(msg.Signer) |
| 218 | if err != nil { |
| 219 | return response, err |
| 220 | } |
| 221 | if !k.adminKeeper.IsAdminAccount(ctx, admintypes.AdminType_PMTPREWARDS, signer) { |
| 222 | return response, errors.Wrap(types.ErrNotEnoughPermissions, fmt.Sprintf("Sending Account : %s", msg.Signer)) |
| 223 | } |
| 224 | params := k.GetPmtpParams(ctx) |
| 225 | rateParams := k.GetPmtpRateParams(ctx) |
| 226 | |
| 227 | // Set Block Rate is needed only if no policy is presently executing |
| 228 | if !types.StringCompare(msg.BlockRate, "") && !k.IsInsidePmtpWindow(ctx) { |
| 229 | blockRate, err := sdk.NewDecFromStr(msg.BlockRate) |
| 230 | if err != nil { |
| 231 | return response, err |
| 232 | } |
| 233 | rateParams.PmtpPeriodBlockRate = blockRate |
| 234 | } |
| 235 | |
| 236 | // Set Running Rate if Needed only if no policy is presently executing |
| 237 | if !types.StringCompare(msg.RunningRate, "") && !k.IsInsidePmtpWindow(ctx) { |
| 238 | runningRate, err := sdk.NewDecFromStr(msg.RunningRate) |
| 239 | if err != nil { |
| 240 | return response, err |
| 241 | } |
| 242 | rateParams.PmtpCurrentRunningRate = runningRate |
| 243 | // inter policy rate should always equal running rate between policies |
| 244 | rateParams.PmtpInterPolicyRate = runningRate |
| 245 | } |
| 246 | k.SetPmtpRateParams(ctx, rateParams) |
| 247 | events := sdk.EmptyEvents() |
| 248 | // End Policy If Needed , returns if not policy is presently |
| 249 | if msg.EndPolicy && k.IsInsidePmtpWindow(ctx) { |
| 250 | params.PmtpPeriodEndBlock = ctx.BlockHeight() |
| 251 | k.SetPmtpParams(ctx, params) |
| 252 | k.SetPmtpEpoch(ctx, types.PmtpEpoch{ |
| 253 | EpochCounter: 0, |
| 254 | BlockCounter: 0, |
| 255 | }) |
| 256 | k.SetPmtpInterPolicyRate(ctx, rateParams.PmtpCurrentRunningRate) |
| 257 | events = events.AppendEvents(sdk.Events{ |
| 258 | sdk.NewEvent( |
| 259 | types.EventTypeEndPmtpPolicy, |
| 260 | sdk.NewAttribute(types.AttributeKeyPmtpPolicyParams, params.String()), |
| 261 | sdk.NewAttribute(types.AttributeKeyPmtpRateParams, rateParams.String()), |
| 262 | sdk.NewAttribute(types.AttributeKeyHeight, strconv.FormatInt(ctx.BlockHeight(), 10)), |
| 263 | ), |
| 264 | sdk.NewEvent( |
| 265 | sdk.EventTypeMessage, |
| 266 | sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), |
| 267 | sdk.NewAttribute(sdk.AttributeKeySender, msg.Signer), |
| 268 | ), |
| 269 | }) |
| 270 | } |
| 271 | ctx.EventManager().EmitEvents(events) |
nothing calls this directly
no test coverage detected