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

Deleting obsolete TimestampDocument

parent 3e4e96b8
No related branches found
No related tags found
No related merge requests found
// 20180612 Robert Martin-Legene <robert@nic.ar>
// It can be difficult to feed large binary "documents" into this
// routine, so it should be changed to accept just the checksum,
// so we'll call this v0.1
pragma solidity ^0.4.24;
contract TimestampDocument {
// This mapping is almost an "associative array"
mapping (bytes32 => uint) private hashes;
// Public functions
//
// Calculate and store the hash for a document
//
function storeDocument( string document ) public {
bytes32 hash = sha256(abi.encodePacked(document));
storeHash( hash );
}
//
// Returns the block number a hash was first seen in.
// zero (0) means not found.
//
function checkDocument( string document ) public view returns (uint) {
return getBlock( sha256(abi.encodePacked(document)) );
}
// Private functions
//
// Stores the hash of the document in the mapping
// if we have not seen the hash before.
//
function storeHash( bytes32 hash ) private {
if ( hashes[hash] == 0 ) {
hashes[hash] = block.number;
}
}
//
// Returns the block number in which the hash was first seen,
// or zero (0) if never seen.
//
function getBlock( bytes32 hash ) private view returns (uint) {
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