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
96954714
Commit
96954714
authored
6 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
TSAv3 is first step in the move towards atomizing services
parent
c19d6cd3
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/TimeStampAuthority3.sol
+60
-0
60 additions, 0 deletions
src/TimeStampAuthority3.sol
with
60 additions
and
0 deletions
src/TimeStampAuthority3.sol
0 → 100644
+
60
−
0
View file @
96954714
// 20180718 Robert Martin-Legene <robert@nic.ar>
// Time stamp authority
// vim:filetype=javascript
pragma
solidity
^
0.5
.
2
;
contract
TimeStampAuthority
{
struct
stamp
{
uint256
stamped
;
address
stamper
;
uint256
blockno
;
}
stamp
[]
stamplist
;
// Provide mappings from what is being stamped, back to the stamplist
mapping
(
uint256
=>
uint256
[]
)
hashstamped
;
// Provide mappings from who is stamping, back to the stamplist
mapping
(
address
=>
uint256
[]
)
hashstamper
;
constructor
()
public
{
// We don't like to assign anything to position 0, so we fill
// it with a dummy which just happens to also have information
// about the creator and the blocknumber it was created.
stamplist
.
push
(
stamp
(
0
,
msg
.
sender
,
block
.
number
)
);
}
// Stores hashes (256 bit uint) in the mapping
function
put
(
uint256
[]
memory
hasharray
)
public
{
uint256
i
=
0
;
uint256
max
=
hasharray
.
length
;
while
(
i
<
max
)
{
uint256
h
=
hasharray
[
i
];
uint256
idx
=
stamplist
.
push
(
stamp
(
h
,
msg
.
sender
,
block
.
number
)
)
-
1
;
hashstamped
[
h
].
push
(
idx
);
hashstamper
[
msg
.
sender
].
push
(
idx
);
i
++
;
}
}
function
getStamplistPos
(
uint256
pos
)
public
view
returns
(
uint256
,
address
,
uint256
)
{
return
(
stamplist
[
pos
].
stamped
,
stamplist
[
pos
].
stamper
,
stamplist
[
pos
].
blockno
);
}
// returns the number of stamps stored with this hash
function
getStampedCount
(
uint256
hash
)
public
view
returns
(
uint256
)
{
return
hashstamped
[
hash
].
length
;
}
// returns the index position into the stamplist
function
getStampedPos
(
uint256
hash
,
uint256
pos
)
public
view
returns
(
uint256
)
{
return
hashstamped
[
hash
][
pos
];
}
// returns the number of stamps stored from this sender
function
getStamperCount
(
address
sndr
)
public
view
returns
(
uint256
)
{
return
hashstamper
[
sndr
].
length
;
}
// returns the index position into the stamplist
function
getStampedPos
(
address
sndr
,
uint256
pos
)
public
view
returns
(
uint256
)
{
return
hashstamper
[
sndr
][
pos
];
}
}
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