Lets say i want to store some data about each address ,through the mapping. My first idea is: store in struct this way:
struct user {
address userAddress;
uint256 someUint:
string someString;
}
mapping (address => user[]) public addressToStruct;
function storeData (uint256 _someUnit, string _someString) external {
addressToStruct[msg.sender].push(user{address(msg.sender), _someUnit, someString});
}
But now i have a new idea to doing this but i don't know which one is gas efficient and if one of them is more secure , and idea is that store them as byte:
mapping (address => bytes[]) public addressToBytes;
function storeData(uint256 _someUint, string _someString) external {
bytes data = abi.encodePacked(_someUint,_someString,address(msg.sender));
addressToBytes[msg.sender].push(data);
}