hashgraph / hedera-services

Crypto, token, consensus, file, and smart contract services for the Hedera public ledger
Apache License 2.0
310 stars 136 forks source link

Improve PbjBytesHasher to reduce garbage #14771

Closed jasperpotts closed 2 months ago

jasperpotts commented 2 months ago

Problem

PbjBytesHasher when hashing protobuf objects it is inefficient as it has to go form PBJ protobuf object to byte[] then to MessageDigest.

Solution

PBJ serialization is stream based and so is MessageDigest. We just need to connect them together. I have filled a PBJ enhancement to add convenience method to make this easy. Once that is implemented then PbjBytesHasher can be updated to use it. See https://github.com/hashgraph/pbj/issues/271 Also as a side note PbjBytesHasher is not the most obvious name as it is very generic, PbjEventHasher would be better 😀

Alternatives

No response

lpetrovic05 commented 2 months ago

PbjBytesHasher is not currently being used, because it was replaced in develop by PbjStreamHasher that does not create a byte[] as an intermediary. So I think we can close this ticket

lpetrovic05 commented 2 months ago

outdated, closing