-
Notifications
You must be signed in to change notification settings - Fork 2.7k
keystore.has_keys behaviour should return the indicies found #7285
Comments
I'd like to work on this, how about these signatures? async fn has_keys(&self, public_keys: &[(Vec<u8>, KeyTypeId)]) -> Option<usize>;
fn has_keys(&self, public_keys: &[(Vec<u8>, KeyTypeId)]) -> Option<usize>; |
@hirschenberger I think we actually should return a |
@bkchr I quickly scanned through the code and most of the time, this function is used in a boolean context, which would also be intuitive when returning an Maybe the design would be more clear if we add another function which returns an index-vec for that special usecase? EDIT: Hmm, although |
Sounds good to me. |
Sorry I don't want to overcomplicate stuff, but having a function called // what is really checked here?
if !keystore.has_keys(....).is_empty() { ... I'd suggest either renaming the function to I also realized, that the current implementation is checking if all of the given public_keys are in the store. When we implement it in one of the above ways, the behaviour changes to if at least one of the keys is in the store. |
There is already a method
As we change the signature, it is not really that easy to mix this up on updating. However, I'm open to a better name than |
But wrapping |
Ok, maybe How about the changed behaviour, not checking if all keys are present, do you think that may cause trouble? |
We check all, if the user wants to know if all are found they can check
This given function is not comparable to what we are doing here and |
Idk, new to substrate and not so familiar with naming. To be honest, the returning of indices works but also seems a little bit C-ish. IMHO, a cleaner solution would be to filter the input Vec and return a new Vec with matching keys. It's your decision. |
I don't know why you want to add |
To make it clear that the returned vector contains the matching indices. In principle the same as you said above:
But if you don't like it, I'd suggest I implement it as you suggested: fn has_keys(&self, public_keys: &[(Vec<u8>, KeyTypeId)]) -> Vec<usize>; PR comes.... |
This is a preparation step to land an optimization by avoiding calling that function multiple times on a remote signer. fixes paritytech#7285
This is a preparation step to land an optimization by avoiding calling that function multiple times on a remote signer. fixes paritytech#7285
This is more efficient when using a remote signer (see paritytech/substrate#7285)
Hey, is anyone still working on this? Due to the inactivity this issue has been automatically marked as stale. It will be closed if no further activity occurs. Thank you for your contributions. |
Bot: still unsolved... |
Follow up to the comment here: paritytech/polkadot#1740 (comment)
The behaviour of the
has_keys
would be slow in cases such as:https://github.com/paritytech/polkadot/blob/9ce9eccae4faa7935bbca9a4200e0978168a46f9/node/network/availability-distribution/src/lib.rs#L582-L586
where the list of keys is iterated so that the first key found is returned. However, in case of a remote signer, this loop would be quite slow.
has_keys
behaviour should be modified so that the index of the first element found is returned so that this index can be used to return the public key.The text was updated successfully, but these errors were encountered: