-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Improve sp_io::storage::clear_prefix API to return the number of key deleted #10288
Comments
Picking this up @thiolliere |
Hello @thiolliere is version 3 of clear_prefix just going to return all the key removed from overlay or return both that of backend and overlay? |
ideally I think we should return: |
I just made a PR for this issue. Can you help check to see what i did @thiolliere |
ah sorry I have mistaken, even if we return the number of key deleted from the overlay, the method For example if both backend and overlay contains some key "abc", doing a clear prefix with a limit of one will delete the key from and overlay and the key from backend, and thus we would decrease the counter by 2. but actually it should be decreased only by one because the key deleted from overlay and the key deleted from backend correspond to the same key in the storage counted map. Considering this I'm not sure implementing the new API is very useful. At least I don't have any usecase for the new API suggested in the issue. I don't know if it worth pursuing the implementation, sorry @dharjeezy |
uhmmm... So are you saying we should scrap(delete) the implementation that i am doing currently and you'd close this issue? @thiolliere |
Should i go ahead and close my PR while you close this issue? @thiolliere |
Yes I think I can close the issue, if people feel like the propose API have usecases then we can reopen. Sorry for having mistaken. |
Currently the api is:
substrate/primitives/io/src/lib.rs
Lines 143 to 175 in 9a00c43
So the return type KillStorageResult only return the number of keys deleted from the backend.
But sometime we also want to know the number of key deleted from the overlay. Like in #10231 to implement CountedStorageMap::remove_all with some limit on the number of key to remove in backend.
To implement this we need to create the version 3 of clear_prefix. returning all the key removed to overlay.
Then we can implement the ability to have a limit in CountedStorageMap::remove_all similarly to StorageMap::remove_all.
The text was updated successfully, but these errors were encountered: