-
Notifications
You must be signed in to change notification settings - Fork 18
(Improvement / Refactor) proposal for storage schema #79
Comments
I think there are some typos in code examples that make things not very clear to me, please double check my understanding :)
on the other hand, there is a mapping from ...
uint256 confirmation_block;
}
mapping (address => PhysicalAddress) public physical_addresses;
... shouldn't it be a mapping from Later, a call to function user_address_by_confirmation_code(
...
if (index == physical_addresses_indexes_by_confirmation_code[confirmation_code_sha3]) {
return (true, index, is_address_confirmed(index));
}
... but if Also, here function confirm_address(
...
if (confirmed) {
revert();
} else {
physical_addresses[index].confirmation_block = block.number;
total_confirmed += 1;
delete physical_addresses_indexes_by_confirmation_code[keccak256(confirmation_code_plain)];
}
... I think a step to add index to ...
delete physical_addresses_indexes_by_confirmation_code[keccak256(confirmation_code_plain)];
confirmed_physical_addresses_indexes.push(index);
... So, if I understand correctly, you're proposing to keep a separate global mapping of physical addresses' keccak256 => physical addresses, while I like the idea of accessing an address in a single call without
On the other hand, I don't think it's a realistic case when a user would confirm 10+ addresses, most probably < 10, so is there any advantage of introducing new structures compared to |
Thank you for your answer @phahulin. I completely missed the use case where the same physical person would own more than 1 address and would want to register all of them. You are right on this one. The User struct that you are proposing doesn't have a real benefit over the existing one however, I liked the struct User {
uint256 creation_block;
PhysicalAddress[] physical_addresses;
uint256[] confirmed_physical_addresses_indexes;
} we don't need the |
@Janther Yes, this is probably an unlikely situation to have more then 10 addresses per user, so I think we can close this issue |
What is it? (leave one option)
(Improvement)
proposal (i.e. some existing feature can be improved)(Refactor)
proposal (i.e. no new features or updates, just code optimization/library updates)What feature are you talking about?
I've been tinkering with other possibilities to improve the current schema of users and arrays of addresses.
I propose to store the addresses in a mapping where the keys will be the result of
keccak256(name, country, state, city, location, zip)
of each address.Maintaining the same behaviour the
User
will have an array ofbytes32
of every physical address associated.This should open new possibilities like:
These are only possibilities that can be made if we rearrange slightly the storing schema. We don't need to implement these but consider changing the schema.
The text was updated successfully, but these errors were encountered: