Merge pull request #15 from 67P/refactor/ipfs-naming-convention

Rename IPFS hash names to be more consistent
This commit is contained in:
fsmanuel 2018-04-07 22:37:25 +02:00 committed by GitHub
commit 170532a128
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 16 deletions

View File

@ -8,7 +8,7 @@ contract Contributors is Upgradeable {
struct Contributor { struct Contributor {
address account; address account;
bytes32 profileHash; bytes32 ipfsHash;
uint8 hashFunction; uint8 hashFunction;
uint8 hashSize; uint8 hashSize;
bool isCore; bool isCore;
@ -19,7 +19,7 @@ contract Contributors is Upgradeable {
mapping (uint => Contributor) public contributors; mapping (uint => Contributor) public contributors;
uint256 public contributorsCount; uint256 public contributorsCount;
event ContributorProfileUpdated(uint id, bytes32 oldProfileHash, bytes32 newProfileHash); event ContributorProfileUpdated(uint id, bytes32 oldIpfsHash, bytes32 newIpfsHash);
event ContributorAddressUpdated(uint id, address oldAddress, address newAddress); event ContributorAddressUpdated(uint id, address oldAddress, address newAddress);
event ContributorAdded(uint id, address _address); event ContributorAdded(uint id, address _address);
@ -51,17 +51,17 @@ contract Contributors is Upgradeable {
ContributorAddressUpdated(_id, _oldAddress, _newAddress); ContributorAddressUpdated(_id, _oldAddress, _newAddress);
} }
function updateContributorProfileHash(uint _id, uint8 _hashFunction, uint8 _hashSize, bytes32 _profileHash) public onlyRegistryContractFor('Operator') { function updateContributorIpfsHash(uint _id, bytes32 _ipfsHash, uint8 _hashFunction, uint8 _hashSize) public onlyRegistryContractFor('Operator') {
Contributor storage c = contributors[_id]; Contributor storage c = contributors[_id];
bytes32 _oldProfileHash = c.profileHash; bytes32 _oldIpfsHash = c.ipfsHash;
c.profileHash = _profileHash; c.ipfsHash = _ipfsHash;
c.hashFunction = _hashFunction; c.hashFunction = _hashFunction;
c.hashSize = _hashSize; c.hashSize = _hashSize;
ContributorProfileUpdated(_id, _oldProfileHash, c.profileHash); ContributorProfileUpdated(_id, _oldIpfsHash, c.ipfsHash);
} }
function addContributor(address _address, uint8 _hashFunction, uint8 _hashSize, bytes32 _profileHash, bool isCore) public onlyRegistryContractFor('Operator') { function addContributor(address _address, bytes32 _ipfsHash, uint8 _hashFunction, uint8 _hashSize, bool isCore) public onlyRegistryContractFor('Operator') {
uint _id = contributorsCount + 1; uint _id = contributorsCount + 1;
if (contributors[_id].exists != true) { if (contributors[_id].exists != true) {
Contributor storage c = contributors[_id]; Contributor storage c = contributors[_id];
@ -69,7 +69,7 @@ contract Contributors is Upgradeable {
c.isCore = isCore; c.isCore = isCore;
c.hashFunction = _hashFunction; c.hashFunction = _hashFunction;
c.hashSize = _hashSize; c.hashSize = _hashSize;
c.profileHash = _profileHash; c.ipfsHash = _ipfsHash;
c.account = _address; c.account = _address;
contributorIds[_address] = _id; contributorIds[_address] = _id;
@ -108,10 +108,10 @@ contract Contributors is Upgradeable {
return contributors[id]; return contributors[id];
} }
function getContributorById(uint _id) view returns (address account, bytes32 profileHash, uint8 hashFunction, uint8 hashSize, bool isCore, bool exists, uint balance ) { function getContributorById(uint _id) view returns (address account, bytes32 ipfsHash, uint8 hashFunction, uint8 hashSize, bool isCore, uint balance, bool exists ) {
Contributor c = contributors[_id]; Contributor c = contributors[_id];
account = c.account; account = c.account;
profileHash = c.profileHash; ipfsHash = c.ipfsHash;
hashFunction = c.hashFunction; hashFunction = c.hashFunction;
hashSize = c.hashSize; hashSize = c.hashSize;
isCore = c.isCore; isCore = c.isCore;

View File

@ -53,18 +53,18 @@ contract Operator is Upgradeable {
return contributorsContract().coreContributorsCount(); return contributorsContract().coreContributorsCount();
} }
function addContributor(address _address, bytes32 _profileHash, uint8 _hashFunction, uint8 _hashSize, bool _isCore) public coreOnly { function addContributor(address _address, bytes32 _ipfsHash, uint8 _hashFunction, uint8 _hashSize, bool _isCore) public coreOnly {
contributorsContract().addContributor(_address, _hashFunction, _hashSize, _profileHash, _isCore); contributorsContract().addContributor(_address, _ipfsHash, _hashFunction, _hashSize, _isCore);
} }
function updateContributorProfileHash(uint _id, bytes32 _profileHash, uint8 _hashFunction, uint8 _hashSize) public coreOnly { function updateContributorIpfsHash(uint _id, bytes32 _ipfsHash, uint8 _hashFunction, uint8 _hashSize) public coreOnly {
contributorsContract().updateContributorProfileHash(_id, _hashFunction, _hashSize, _profileHash); contributorsContract().updateContributorIpfsHash(_id, _ipfsHash, _hashFunction, _hashSize);
} }
function getContributor(uint _id) view public returns (address account, uint8 hashFunction, uint8 hashSize, bytes32 profileHash, bool isCore) { function getContributor(uint _id) view public returns (address account, bytes32 ipfsHash, uint8 hashFunction, uint8 hashSize, bool isCore) {
bool exists; bool exists;
(account, profileHash, hashFunction, hashSize, isCore, exists) = contributorsContract().contributors(_id); (account, ipfsHash, hashFunction, hashSize, isCore, exists) = contributorsContract().contributors(_id);
require(exists); require(exists);
} }