I have a library and a contract like this:
pragma solidity ^0.4.8;
library LibUserData{
struct data{
string firstName;
string lastName;
}
function setName(data storage _data, string _firstName, string _lastName){
_data.firstName = _firstName;
_data.lastName = _lastName;
}
}
contract User{
mapping (address => LibUserData.data) public userData;
function setName(address _address, string _firstName, string _lastName){
LibUserData.setName(userData[_address], _firstName, _lastName);
}
function getName(address _address) constant returns (string, string) {
return (userData[_address].firstName, userData[_address].firstName);
}
}
I deploy the library LibUserData first (and only once) and insert its address in the bytecode of the User contract. Then I deploy the User contract with this bytecode. If I call the function setName() of the User contract the data will obviously be stored in the library LibUserData. Then I deploy the User contract again with the same bytecode (same address of library LibUserData). And I call the function setName() again from the second User contract. What happens now? Will the data be stored in the same LibUserData like in the first User contract or is a new instance of the LibUserData library created?