I'm trying to build multi-threading in my contract by mapping a mapping:

struct Structure {
    bytes32 byteCode;
    uint integer;

//Mapping a structure to the address in order to hold address specific information.
mapping (address => Structure[]) mapping1;

//Mapping a mapping to uint256 in order to keep track of which thread it is concerning.
mapping (uint256 => mapping1) mapping2;

I am getting errors all over the contract wherever I try to do mappings like in the code above. The error is:

 Name has to refer to a struct, enum or contract.
mapping (uint256 => mapping1) public mapping2;

Any ideas about a workaround or should I just hope that next version of Solidity supports this kind of linking?

EDIT: I worked around the issue by using structures that have sufficient indexes in order for my mechanics to work. Unfortunately this method is way more wasteful than double linking, so I still hope someone knows the answer to my issue.


As the error message notifies, you can't map to a dynamic var.

mapping (uint256 => mapping1) public mapping2;    

should be :

mapping (uint256 => mapping (address => Structure[]) ) public mapping2;

you can use some implementations as LibCLL : https://github.com/o0ragman0o/LibCLL

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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