I am bringing this topic as I had a thought and I was working on my project and asked myself what if the storage item could accepts 2 keys ( not StorageDoubleMap) but take it as if one of the predefined keys is provided , we can then get access of the stored value.
So my questions are:
I know I can implement this but any security issues concerning this?
I think the caveat is I need to pre-define the keys at storage initialization right?
Any feedback on this thought and do you guys think this will be an add up or not something useful at all?
I guess I’m not really seeing the difference from a StorageDoubleMap or a StorageMap with a tuple key, do you mind giving a code snippet example of what you mean?
type Example = StorageOrMap<_,hasher, key1,key2,value>;
Now when setting the value
Example::insert(key1, key2, value);
But when accessing the value
Example::get(key1 or key2);
So its like you have k = 2, total number of keys but you only need n=1 key from k space to access the value.
Since storage keys are identified by their hash, going from left to right, you can easily get the values that share the same key 1, but I don’t think there’s a reasonable way of using either key 1 or key 2. I also can’t seem to think of a good use case for it, as you could simply use a K->V map and store both keys pointing to the same value.