I have a mapping table whcich stores multiple hashes into that table. What I want to do is that I want the user to add another hash with setinstructors() function and then try to look whether the same hash already exists in the mapping table or not. If the same hash already exists in the table then it should return true esle false. Here's my code:
pragma solidity ^0.4.18;
contract Hash{
bytes32 comphash;
struct hashstruct{
bytes32 fhash;
}
mapping (uint => hashstruct) hashstructs;
uint[] public hashAccts;
function setinstructor(uint _uint,string _fhash) public {
var a = hashstructs[_uint];
a.fhash = sha256(_fhash);
hashAccts.push(_uint) -1;
}
function getInstructor(uint ins) view public returns (bytes32) {
return (hashstructs[ins].fhash);
}
function count() view public returns (uint) {
return hashAccts.length;
}
function setinstructors(string _comphash) public {
comphash = sha256(_comphash);
}
function getInstructors() public constant returns (bytes32) {
return (comphash);
}
}