massa
massa copied to clipboard
Optimize `get_address_deferred_credits` `in pos_final_state.rs`
Currently, we iterate over all the DeferredCredits keys while we're only interested in a specific address.
We don't have to visit every keys. We might want instead to use a while loop, and query only the keys corresponding to the wanted address.
slot_serializer.serialize(cur_slot, &mut key)
addr_serializer.serialize(address, &mut key)
deferred_credit_prefix!(key)
In the case it's not found, go immediatly to the next existing slot key instead of iterating over all addresses.
Originally posted by @Leo-Besancon in https://github.com/massalabs/massa/pull/4152#discussion_r1247574441