Is it possible to have a struct inside a struct? I am not sure about the data type internals, but I was basically trying to do something like (pseudo-code):
library IpfsUtils {
struct IpfsHash {
bytes32 hash;
uint8 hashFunction;
uint8 hashSize;
}
function insert(bytes _hash) {}
function combine() {}
}
contract Members {
struct Member {
IpfsUtils.IpfsHash profile;
uint id;
}
mapping (address => Member) public members;
function addMember(uint id, bytes profileHash) {
Member m = members[msg.sender];
m.id = id;
m.profile.insert(profileHash);
}
}
I'm trying to store an IPFS hash with fixed length data types and I thought about extracting the storage of the ipfs hash function, size and the actual bytes32 hash into its own struct.
Can someone point me somewhere to learn more about the internals?
EDIT:
nested structs are possible. BUT the the mapping (here members
) can not be public causing the following error: TypeError: Internal type is not allowed for public state variable