Closed Janther closed 6 years ago
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
blockchain/contracts/ProofOfPhysicalAddress.sol | 13 | 16 | 81.25% | ||
<!-- | Total: | 13 | 16 | 81.25% | --> |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
blockchain/contracts/ProofOfPhysicalAddress.sol | 14 | 35.53% | ||
<!-- | Total: | 14 | --> |
Totals | |
---|---|
Change from base Build 218: | 0.6% |
Covered Lines: | 764 |
Relevant Lines: | 1067 |
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
blockchain/contracts/ProofOfPhysicalAddress.sol | 14 | 18 | 77.78% | ||
<!-- | Total: | 14 | 18 | 77.78% | --> |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
blockchain/contracts/ProofOfPhysicalAddress.sol | 1 | 35.29% | ||
<!-- | Total: | 1 | --> |
Totals | |
---|---|
Change from base Build 218: | 0.6% |
Covered Lines: | 764 |
Relevant Lines: | 1068 |
@Janther should we also get rid of comparisons with empty strings in favour of keccak256
or it's not worth it?
// now
require(!str_eq(name, ''));
// maybe?
bytes32 empty_hash = keccak256('');
require( keccak256(name) != empty_hash );
and remove function str_eq
altogether?
That's the plan for the next PR, I have the commit ready but I like to keep PRs atomic. Once this PR is merged, I'll make the next one.
And it will be like this:
// before
require(!str_eq(name, ''));
// after
require(bytes(name).length > 0);
Before submitting a pull request, please provide the following information:
What is it? (leave one option)
(Improvement)
of existing functionality(Refactor)
of existing code (no functionality change)What was the root cause of the problem originally / what feature was missing? Instead of having a byte per byte comparison, addresses are hashed using
keccak256
and that hash is being compared.How does this pull request solve it (in broad terms)? I stored the
keccac256
hash in thePhysicalAddress
struct in the registration and the lookup just checks if the keccak matches.Does it close any open issues? Closes #77
Quick checklist
Additional information
I performed a small refactor in the
register_address
function. Just cleaning up some duplicated code.