I have seen examples like the following code many times:
mapping (bytes32 => mapping (bytes32 => bytes32[])) items;
And I have tried to recreate something similar here:
mapping(address => uint) public addresskey1;
mapping(uint => mapping(address => uint)) public addresskey2;
function addAddress(address _address, uint _pin) public {
addresskey1[_address] = ID;
addresskey2[_pin] = addresskey1[_address];
}
Aside from remix telling me that mappings can't be assigned to, I can't quite figure out what this does. I know that a mapping creates a hash of the keytype which points to a location where the value is stored, but how does it work when
a hash of a key points to another hash of another key which points to the value? My first thought is that the hash immediately tells the computer where to go, and so mapping like this would just create two jumps to the desired value.
In other words, it is a way of creating multiple keys for the same value without having to save the value in multiple locations - but then, the hash of the first mapping must be stored separately anyway, so it wouldn't really save space.
I keep trying to play around with this, but I cannot figure out what it does.