Skip to content

Consider removing NoteAssets::add_asset #2525

@PhilippGackstatter

Description

@PhilippGackstatter

NoteAssets::add_asset recomputes the commitment every time. This currently results in re-hashing the assets whenever an asset is added to a note due to OutputNoteBuilder::add_asset forwarding to NoteAssets::add_asset in the tx host.

To make this a bit more efficient:

  • Store assets in a Vec in OutputNoteBuilder and delay NoteAssets creation until OutputNoteBuilder::build is called.
  • In addition to the above, we can consider making NoteAssets immutable by removing add_asset. It seems to only exist for the purpose of calling it in OutputNoteBuilder. This is more in line with most other types in protocol, which are immutable. If one wants to mutate an existing NoteAssets, it can be converted (into_vec(self) -> Vec<Asset>) and then rebuilt after one or multiple assets were added to the vec.

Metadata

Metadata

Labels

good first issueGood for newcomersrustIssues that affect or pull requests that update Rust code

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions