Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nucleo
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
blockchain
nucleo
Commits
86d232d1
Commit
86d232d1
authored
6 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
Deleting obsolete TimestampDocument
parent
3e4e96b8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/contract.TimestampDocument.sol
+0
-50
0 additions, 50 deletions
src/contract.TimestampDocument.sol
with
0 additions
and
50 deletions
src/contract.TimestampDocument.sol
deleted
100644 → 0
+
0
−
50
View file @
3e4e96b8
// 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];
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment