You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An ideal API probably looks something closer to this (at least as an option):
let key = StateContentKey::AccountTrieNode(...);let trie_node = matchStateNetworkApiClient::get_decoded_content(transport, key){Ok(trie_node) => trie_node,// only a single type can be returned by any key type, so we can skip the enumErr(e) => returnhandle_err(e),};// do_something(trie_node)
I don't know the rust magic to make that happen ^ but it should be straightforward to do a middle-ground solution, like:
let key = StateContentKey::AccountTrieNode(...);let trie_node = matchStateNetworkApiClient::get_decoded_content(transport, key){Ok(StateContentValue::TrieNode(trie_node)) => trie_node,// only a single type can be returned by any key type, so we can skip the enumOk(wrong_type) => panic!("Should never get a different value when looking up a trie node. Got: {wrong_type}"),Err(e) => returnhandle_err(e),};// do_something(trie_node)
I do see that there could be reasons to keep both get_content and get_decoded_content around in the API. Maybe this is pretty low priority, since it amounts to having to make one less function call. (unless we can get the magic solution working)
At the very least, we can add some docs to EncodedTrieNode that say: if you're trying to decode this by hand after making an RPC request, you're probably doing it wrong, and should be using StateContentValue::decode() instead
The text was updated successfully, but these errors were encountered:
carver
added
the
flamingo
Maintenance or downtime for the person on Flamingo rotation to tackle
label
Oct 31, 2024
The problem is that all of these functions (and many more) have the exact same signature but they belong to different traits.
I think it's possible to use some rust magic and create one trait that can be use to abstract this. In that case, it might be possible to add extra functionality, like the one that you suggested.
Inspired by a bug I introduced in glados, and thoughts about how to make it less likely in the future:
ethereum/glados#335 (review)
The current usage pattern goes something like:
An ideal API probably looks something closer to this (at least as an option):
I don't know the rust magic to make that happen ^ but it should be straightforward to do a middle-ground solution, like:
I do see that there could be reasons to keep both
get_content
andget_decoded_content
around in the API. Maybe this is pretty low priority, since it amounts to having to make one less function call. (unless we can get the magic solution working)At the very least, we can add some docs to
EncodedTrieNode
that say: if you're trying to decode this by hand after making an RPC request, you're probably doing it wrong, and should be usingStateContentValue::decode()
insteadThe text was updated successfully, but these errors were encountered: