iron-fish / ironfish

A novel cryptocurrency focused on privacy and accessibility.
https://ironfish.network
Mozilla Public License 2.0
964 stars 577 forks source link

Change `DecryptNotesResponse` to use a sparse serialization format #5049

Closed andiflabs closed 2 weeks ago

andiflabs commented 3 weeks ago

Summary

In the vast majority of the cases, a DecryptNotesResponse will contain zero or close-to-zero decrypted notes. It makes sense to have the serialization of DecryptNotesResponse optimize for those cases.

This changes the serialization size of DecryptNotesResponse from O(null_notes + non_null_notes) to O(non_null_notes).

This introduces a small size overhead in the case where the are a lot of decrypted notes. We could in theory have DecryptNotesResponse choose between sparse and dense serialization based on how many decrypted notes there are, but that case is so rare, and the overhead so small, that it's not worth optimizing for it.

Testing Plan

Unit tests

Documentation

N/A

Breaking Change

N/A