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
80ad026c
Commit
80ad026c
authored
7 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
Made insert.sh and verify.sh behave a bit more as documented
parent
1fb9fecc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/insert.sh
+21
-11
21 additions, 11 deletions
bin/insert.sh
bin/verify.sh
+15
-6
15 additions, 6 deletions
bin/verify.sh
with
36 additions
and
17 deletions
bin/insert.sh
+
21
−
11
View file @
80ad026c
...
...
@@ -3,10 +3,17 @@
if
[
-z
"
${
BFAHOME
}
"
]
;
then
echo
"
\$
BFAHOME not set. Did you source bfa/bin/env ?"
>
&2
;
exit
1
;
fi
source
${
BFAHOME
}
/bin/libbfa.sh
||
exit
1
contract
=
$1
text
=
$2
test
-n
"
${
contract
}
"
||
contract
=
"TimestampDocument"
contract
=
"TimeStampAuthority"
if
[
$#
-eq
0
]
then
text
=
"Hello World!"
elif
[
$#
-eq
1
]
then
text
=
"
$1
"
else
contract
=
"
$1
"
text
=
"
$2
"
fi
if
[
!
-e
"
${
contract
}
"
-a
-r
"
${
BFANETWORKDIR
}
/contracts/
${
contract
}
"
]
then
contract
=
${
BFANETWORKDIR
}
/contracts/
${
contract
}
...
...
@@ -16,17 +23,20 @@ test -L "${contract}" &&
test
-n
"
${
contract
}
"
basecontract
=
$(
basename
"
${
contract
}
"
)
test
-n
"
${
basecontract
}
"
abi
=
$(
cat
${
contract
}
/abi
)
abi
=
$(
cat
${
BFANETWORKDIR
}
/contracts/
${
contract
}
/abi
)
test
-n
"
${
abi
}
"
test
-n
"
$text
"
||
text
=
"Hello World!"
js
=
$(
bfamktemp
)
js
=
$(
mktemp
)
sum
=
$(
echo
$text
|
sha256sum
|
cut
-c
-64
)
cleanup
"
$js
"
cat
>
$js
<<
EOT
var mycontract = eth.contract(
JSON.parse(
${
abi
}
)
)
var thecontract = mycontract.at("
${
basecontract
}
")
;
console.log ( thecontract.
storeDocumen
t.sendTransaction( "
${
text
}
", {from: eth.accounts[0], gas: 1000000} ) )
var mycontract = eth.contract(
${
abi
}
)
var thecontract = mycontract.at("
${
basecontract
}
")
console.log ( thecontract.
pu
t.sendTransaction( "
${
sum
}
", {from: eth.accounts[0], gas: 1000000} ) )
EOT
out
=
$(
bfamktemp
)
geth
--datadir
node1
--exec
"loadScript(
\"
${
js
}
\"
)"
attach ipc:node1/geth.ipc
>
${
out
}
out
=
$(
mktemp
)
cleanup
"
$out
"
geth_exec_js
"
${
js
}
"
>
${
out
}
if
[
`
wc
-l
<
${
out
}
`
=
2
-a
`
tail
-1
<
${
out
}
`
=
"true"
]
then
trans
=
`
head
-1
<
${
out
}
`
...
...
This diff is collapsed.
Click to expand it.
bin/verify.sh
+
15
−
6
View file @
80ad026c
...
...
@@ -4,10 +4,17 @@
if
[
-z
"
${
BFAHOME
}
"
]
;
then
echo
"
\$
BFAHOME not set. Did you source bfa/bin/env ?"
>
&2
;
exit
1
;
fi
source
${
BFAHOME
}
/bin/libbfa.sh
||
exit
1
contract
=
$1
text
=
$2
test
-n
"
${
contract
}
"
||
contract
=
"TimestampDocument"
contract
=
"TimestampDocument"
if
[
$#
-eq
0
]
then
text
=
"Hello World!"
elif
[
$#
-eq
1
]
then
text
=
"
$1
"
else
contract
=
"
$1
"
text
=
"
$2
"
fi
if
[
!
-e
"
${
contract
}
"
-a
-r
"
${
BFANETWORKDIR
}
/contracts/
${
contract
}
"
]
then
contract
=
${
BFANETWORKDIR
}
/contracts/
${
contract
}
...
...
@@ -20,13 +27,15 @@ test -n "${basecontract}"
abi
=
$(
cat
${
contract
}
/abi
)
test
-n
"
${
abi
}
"
test
-n
"
$text
"
||
text
=
"Hello World!"
js
=
$(
bfamktemp
)
js
=
$(
mktemp
)
cleanup
"
$js
"
cat
>
${
js
}
<<
EOT
var mycontract = eth.contract(JSON.parse(
${
abi
}
))
var thecontract = mycontract.at("
${
basecontract
}
");
console.log ( thecontract.checkDocument.call( "
${
text
}
" ) )
EOT
out
=
$(
bfamktemp
)
out
=
$(
mktemp
)
cleanup
"
$out
"
geth
--datadir
node1
--exec
"loadScript(
\"
${
js
}
\"
)"
attach ipc:node1/geth.ipc
>
${
out
}
if
[
`
wc
-l
<
${
out
}
`
=
2
-a
`
tail
-1
<
${
out
}
`
=
"true"
]
then
...
...
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