0

Lets assume we have an ink! smart contract

On a vanilla Mapping

alpha: Mapping<[u8;32], Astruct>

we can use

self.alpha.remove(&somehash)

My question is this: if we have the following mapping that takes a tuple

beta: Mapping<(String, [u8;20]) , Bstruct>

then we want to

self.beta.remove((&somestring, _))

Obviously the above does not and is not expected to work

Question: There are cases where for a given string in this case somestring as seen above for any value of the 2nd element of the tuple, we want to remove storage. We understand that we can store in a Vec the 2nd tuple element values and then loop using

self.beta.remove((&somestring, &a1)) 
...
self.beta.remove((&somestring, &a1000000)) 

but we have been wondering if there is a better method to maybe reset the above beta Mapping to the default removing all storage for a specific 1st tupple element value.

For example self.beta = Mapping::default(); would not be acceptable business logic

The concept of self.beta.remove((&somestring, _)) makes business logic sense but is not acceptable

Any suggestions please?

1 Answer 1

0

It seems that with the current existing technology, the above way of looping through the 2nd tuple element, is the acceptable solution. Credits and many thanks to the Phala team for their support.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.