Skip to content
Snippets Groups Projects
Commit 82aadaf4 authored by Robert Martin-Legene's avatar Robert Martin-Legene
Browse files

bytes32 would have worked if we sent a binary string, but uint256 seems much...

bytes32 would have worked if we sent a binary string, but uint256 seems much more friendly. We also now accept an array of uint256s for put'ing.
parent 86d232d1
No related branches found
No related tags found
No related merge requests found
...@@ -5,17 +5,22 @@ pragma solidity ^0.4.24; ...@@ -5,17 +5,22 @@ pragma solidity ^0.4.24;
contract TimeStampAuthority { contract TimeStampAuthority {
// This mapping is almost an "associative array" // This mapping is almost an "associative array"
mapping (bytes32 => uint) private hashes; mapping (uint256 => uint) private hashstore;
// Stores the hash of the document in the mapping // Stores hashes (256 bit uint) of a document in the mapping
function put( bytes32 hash ) public { function put( uint256[] hasharray ) public {
require( hashes[hash] == 0, "That checksum has already been stored." ); uint256 i = hasharray.length;
hashes[hash] = block.number; while (i>0) {
i--;
uint256 h = hasharray[i];
if (hashstore[h] == 0) {
hashstore[h] = block.number;
}
}
} }
// Returns the block number in which the hash was first seen // Returns the block number in which the hash was first seen
function get( bytes32 hash ) public view returns (uint) { function get( uint256 hash ) public view returns (uint) {
require( hashes[hash] != 0, "That checksum has never been stored." ); return hashstore[hash];
return hashes[hash];
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment