Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TSA NG
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Renzo Mauro Ontivero
TSA NG
Commits
a7027dc8
Commit
a7027dc8
authored
5 years ago
by
Mariano Absatz (git)
Browse files
Options
Downloads
Patches
Plain Diff
Agrego comentarios y aclaraciones. El código del smart contract en sí es idéntico
parent
d257f8b6
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
contract/contracts/Stamper.sol
+18
-10
18 additions, 10 deletions
contract/contracts/Stamper.sol
with
18 additions
and
10 deletions
contract/contracts/Stamper.sol
+
18
−
10
View file @
a7027dc8
// 20190401 Robert Martin-Legene <robert@nic.ar>
// 20190507 Andres Blanco <ablanco@siu.edu.ar>
// Stamper
// vim:filetype=javascript
...
...
@@ -10,6 +11,8 @@ contract Stamper {
address
stamper
;
uint256
blockNo
;
}
// Lista de stamps (cada entrada tiene el hash del object, la cuenta que lo envio
// y el numero de bloque en que se guardo)
Stamp
[]
stampList
;
// Mapping de objects stampeados a la stampList
...
...
@@ -35,19 +38,23 @@ contract Stamper {
stampList
.
push
(
Stamp
(
0
,
msg
.
sender
,
block
.
number
));
}
// Stampear una lista de objects (hashes)
// Stampear una lista de objects (hashes)
recibido como array
function
put
(
bytes32
[]
memory
objectList
)
public
{
uint256
i
=
0
;
uint256
max
=
objectList
.
length
;
while
(
i
<
max
)
{
bytes32
h
=
objectList
[
i
];
// stampList.push devuelve la longitud, restamos 1 para usar como indice
uint256
idx
=
stampList
.
push
(
Stamp
(
h
,
msg
.
sender
,
block
.
number
))
-
1
;
hashObjects
[
h
].
push
(
idx
);
hashStampers
[
msg
.
sender
].
push
(
idx
);
emit
Stamped
(
msg
.
sender
,
h
,
block
.
number
);
// este object
bytes32
object
=
objectList
[
i
];
// lo agregamos a la stampList
// stampList.push devuelve la longitud, restamos 1 para usar como indice de la nueva entrada
uint256
newObjectIndex
=
stampList
.
push
(
Stamp
(
object
,
msg
.
sender
,
block
.
number
))
-
1
;
// lo mapeamos desde la lista de objects
hashObjects
[
object
].
push
(
newObjectIndex
);
// lo mapeamos desde la lista de stampers
hashStampers
[
msg
.
sender
].
push
(
newObjectIndex
);
emit
Stamped
(
msg
.
sender
,
object
,
block
.
number
);
i
++
;
}
...
...
@@ -71,7 +78,8 @@ contract Stamper {
return
hashObjects
[
object
][
pos
];
}
// devuelve el nro de bloque en el que stamper registro object. Si no fue stampeado devuelve 0
// devuelve el nro de bloque en el que este stamper registro este object por primera vez
// Si no fue stampeado por este stamper devuelve 0
function
getBlockNo
(
bytes32
object
,
address
stamper
)
public
view
returns
(
uint256
)
{
uint
length
=
hashObjects
[
object
].
length
;
...
...
@@ -91,7 +99,7 @@ contract Stamper {
return
hashStampers
[
stamper
].
length
;
}
// devuelve la ubicacion en la
s
stamp
l
ist de un Stamp especifico de este stamper
// devuelve la ubicacion en la stamp
L
ist de un Stamp especifico de este stamper
function
getStamperPos
(
address
stamper
,
uint256
pos
)
public
view
returns
(
uint256
)
{
return
hashStampers
[
stamper
][
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