Skip to content

Commit

Permalink
chore(x/swingset): Add comments to chargeAdmission (#10440)
Browse files Browse the repository at this point in the history
## Description
Extracted from #10165.

### Security Considerations
n/a

### Scaling Considerations
n/a

### Documentation Considerations
n/a

### Testing Considerations
n/a

### Upgrade Considerations
n/a
  • Loading branch information
gibson042 authored Nov 10, 2024
1 parent 160f38d commit e7af58f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions golang/cosmos/x/swingset/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ func chargeAdmission(
msgs []string,
storageLen uint64,
) error {
// A flat charge for each transaction.
beans := beansPerUnit[BeansPerInboundTx]
// A charge for each message in the transaction.
beans = beans.Add(beansPerUnit[BeansPerMessage].MulUint64((uint64(len(msgs)))))
// A charge for the total byte length of all messages.
for _, msg := range msgs {
beans = beans.Add(beansPerUnit[BeansPerMessageByte].MulUint64(uint64(len(msg))))
}
// A charge for persistent storage.
beans = beans.Add(beansPerUnit[BeansPerStorageByte].MulUint64(storageLen))

return keeper.ChargeBeans(ctx, beansPerUnit, addr, beans)
Expand Down

0 comments on commit e7af58f

Please sign in to comment.