git-consensus / contracts

Converts the informal ownership structure of an open-source git project to a formal DAO, with token distribution mechanisms for contributors.
GNU General Public License v3.0
13 stars 0 forks source link

use single mapping for commits and tags #42

Closed Bryce-Soghigian closed 2 years ago

Bryce-Soghigian commented 2 years ago

Description

From issue #36:

Having two mappings is actually completely unnecessary:

mapping(bytes20 => address) private commitToOwnerAddr;
mapping(bytes20 => address) private tagToTokenAddr;

because no SHA-1 hash from CommitData could ever overlap with TagData.

Can simplify the GitConensus interface from:

addCommit(CommitData commit) 
addRelease(TagData tag, bytes20[] hashes, uint256[] values) 
commitAddr(bytes20 commitHash) 
commitExists(bytes20 commitHash) 
tagAddr(bytes20 tagHash) 
tagExists(bytes20 tagHash)

to

addCommit(CommitData commit) 
addRelease(TagData tag, bytes20[] hashes, uint256[] values) 
hashAddr(bytes20 hash) 
hashExists(bytes20 hash) 

It can be argued that the former gives more information about the type of hash (commit vs. tag), but this does not seem worth the trade-off of having a more complex interface.

Test Coverage

I modified the interfaces to only use one mapping of hashes to addresses. I made the appropriate changes everywhere.

Fixes #36