Is adding transaction metadata inside filterTransaction allowed?

I have a plugin with a filterTransaction. This filter calculates some values to do its job, and then these values are later recalculated when the transaction is accepted (to become part of the plugin state). I’d like to avoid this recalculation is I can, so I was wondering if it’s OK for the filterTransaction to add them to the transaction as metadata. Will this break anything in PM? Is it playing outside the rules?

Even if setting the metadata is OK in this context, is it the best way to communicate this data?

Technically, it isn’t—a filter should just return a value and do nothing else. Practically, you can probably get away with this if you don’t add any metadata that affects how other filters and plugins are handling the transaction.