Granola-Team / mina-indexer

The Mina Indexer is a re-imagined version of the software collectively called the "Mina archive node."
Apache License 2.0
19 stars 10 forks source link

Make `TxnHash` struct #1109

Closed Isaac-DeFrain closed 1 month ago

Isaac-DeFrain commented 4 months ago

We should use pub struct TxnHash(pub String) over String

trevorbernard commented 4 months ago

We should strongly type all the things

n1tranquilla commented 1 month ago

There are some performance considerations around this. Currently we're passing around &str and refactoring to TxnHash(pub String) would result in many more memory allocations on the heap. There probably are some ways around this using Cow, but I think it is a little beyond me at this moment.

trevorbernard commented 1 month ago

Cow isn't necessary if you aren't mutating a shared resource. Just pass in the &TxnHash. This feels like prematurely optimization. Even better would be to use the txh hashes binary representation as the value rather than it's string-ified representation.