mina-indexer icon indicating copy to clipboard operation
mina-indexer copied to clipboard

Make `TxnHash` struct

Open Isaac-DeFrain opened this issue 1 year ago • 1 comments

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

Isaac-DeFrain avatar Jun 11 '24 21:06 Isaac-DeFrain

We should strongly type all the things

trevorbernard avatar Jun 24 '24 14:06 trevorbernard

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.

nathan-tranquilla avatar Sep 16 '24 14:09 nathan-tranquilla

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.

trevorbernard avatar Sep 16 '24 17:09 trevorbernard