-
Notifications
You must be signed in to change notification settings - Fork 18
(Refactor / Improvement) Using the keccak for comparing inputs #77
Comments
@Janther could you elaborate on
At the present moment we store addresses for each wallet as an array - this is probably not the best way. But the advantage of this is that we can find all addresses linked to the wallet. Do you propose we store an additional mapping of |
Yes mainly something like this: contract ProofOfPhysicalAddress {
mapping (bytes32 => bool) public addressExists;
function register_address(
string name,
string country,
string state,
string city, string location, string zip,
uint256 price_wei,
bytes32 confirmation_code_sha3, uint8 sig_v, bytes32 sig_r, bytes32 sig_s)
public payable
{
// ... normal register_address logic plus following line ... //
addressExists[keccak256(name, country, state, city, location, zip)] = true;
}
} Then you can easily ask if an address has been registered. This is just an idea since the important part here is that we agree that |
Yes, we can agree that using I'm trying to understand if there is any benefit to store both array of addresses and an additional mapping of addresses. But this discussion should probably go to #79 |
In the case of having a mapping of Users containing an array of addresses, it makes sense to have a mapping of booleans just to show that an address does exist without having to go through the Users. |
@pablofullana can I start working on the part that me and @Janther agreed on? that is
I think it will improve the code to a large extent. |
Works for me. @vbaranov any concerns on your side? |
no, I have no concerns about it |
On the lookup by physical address
Instead of looping over every character on the string comparison for every input, the system could benefit from hashing the
keccak
of the attributes when storing it and using it for comparison.The
keccak
could also be used as an index or a proof of the existence of an address.The text was updated successfully, but these errors were encountered: