Created
July 22, 2018 21:36
-
-
Save mayorcoded/b437709efea15c8fb681ab0f8c64e4b7 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=true&gist=
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.4.23; | |
contract OwnershipProof{ | |
//FileDetails structure | |
struct FileDetails { | |
uint256 timestamp; | |
string owner; | |
} | |
//mapping of owners to FileDetails | |
mapping (string => FileDetails) files; | |
//event to log while file is added | |
event logFileAddedStatus(bool status,uint256 timestamp, string owner, string fileHash); | |
//add a file to the files map if it does not exist | |
function addFile(string owner, string fileHash) public { | |
if(files[fileHash].timestamp == 0){ | |
files[fileHash] = FileDetails(block.timestamp, owner); | |
emit logFileAddedStatus(true, block.timestamp, owner, fileHash); | |
}else{ | |
emit logFileAddedStatus(false, block.timestamp, owner, fileHash); | |
} | |
} | |
//get an exisiting file | |
function getFile(string fileHash) public view returns(uint256 timestamp, string owner){ | |
return (files[fileHash].timestamp, files[fileHash].owner); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment