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
1fb9fecc
Commit
1fb9fecc
authored
6 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
Streamlining things a bit more.
parent
08fe2453
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bin/attach.sh
+1
-2
1 addition, 2 deletions
bin/attach.sh
bin/create.contract
+17
-12
17 additions, 12 deletions
bin/create.contract
bin/libbfa.sh
+13
-12
13 additions, 12 deletions
bin/libbfa.sh
bin/start.sh
+6
-0
6 additions, 0 deletions
bin/start.sh
with
37 additions
and
26 deletions
bin/attach.sh
+
1
−
2
View file @
1fb9fecc
...
...
@@ -4,5 +4,4 @@
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
bfaconfig node
geth attach ipc:
${
BFANODEDIR
}
/geth.ipc
geth_attach
This diff is collapsed.
Click to expand it.
bin/create.contract
+
17
−
12
View file @
1fb9fecc
...
...
@@ -6,31 +6,36 @@ source ${BFAHOME}/bin/libbfa.sh || exit 1
function
create
{
workdir
=
$(
bfamktemp
-p
.
-d
)
json
=
$(
solc
--optimize
--combined-json
abi,bin
$filename
)
;
test
$?
eq 0
abi
=
$(
echo
"
$json
"
| jq
-rM
".contracts.
${
prefix
}
.abi"
)
;
test
$?
eq 0
bin
=
$(
echo
"
$json
"
| jq
-rM
".contracts.
${
prefix
}
.bin"
)
;
test
$?
eq 0
workdir
=
$(
mktemp
-p
.
-d
)
cleanup
"
$workdir
"
json
=
$(
solc
--optimize
--combined-json
abi,bin
$filename
)
;
test
$?
=
0
prefix
=
$(
echo
"
$json
"
| jq
-M
'.contracts | keys | .[0]'
)
;
abi
=
$(
echo
"
$json
"
| jq
-rM
".contracts.
${
prefix
}
.abi"
)
;
test
$?
=
0
bin
=
$(
echo
"
$json
"
| jq
-rM
".contracts.
${
prefix
}
.bin"
)
;
test
$?
=
0
# Save abi for future use
echo
$abi
>
${
workdir
}
/abi
# We could save the bin, but we don't actually use it later, plus
# it gets stored in the blockchain
#echo $bin > ${workdir}/bin
js
=
$(
bfamktemp
)
js
=
$(
mktemp
)
cleanup
"
$js
"
cat
>
$js
<<
EOT
var mycontract = eth.contract(
JSON.parse(
$abi
)
)
var mycontract = eth.contract(
$abi
)
var transaction = mycontract.new( { from: eth.accounts[0], data: "0x
${
bin
}
", gas: 1000000 } )
var rcpt
while ( !rcpt )
{
admin.sleepBlocks( 1 )
;
rcpt = eth.getTransactionReceipt( transaction.transactionHash )
;
admin.sleepBlocks( 1 )
rcpt = eth.getTransactionReceipt( transaction.transactionHash )
}
var address = rcpt.contractAddress
;
var pubcontract = mycontract.at(address)
;
console.log( pubcontract.address )
;
var address = rcpt.contractAddress
var pubcontract = mycontract.at(address)
console.log( pubcontract.address )
EOT
echo
'*** Creating contract. This will take at least 16 seconds.'
outfile
=
$(
geth_exec_js
$js
)
outfile
=
$(
bfamktemp
)
cleanup
"
$outfile
"
geth_exec_js
$js
>
$outfile
if
[
`
wc
-l
<
$outfile
`
=
2
-a
`
tail
-1
<
$outfile
`
=
"true"
]
then
addr
=
`
head
-1
<
$outfile
`
...
...
This diff is collapsed.
Click to expand it.
bin/libbfa.sh
+
13
−
12
View file @
1fb9fecc
...
...
@@ -32,25 +32,16 @@ function cleanup
rm
-rf
$cleanup_files
}
# calls mktemp and then cleanup - makes other scripts more compact
function
bfamktemp
{
local
file
=
$(
mktemp
"
$@
"
)
cleanup
$file
echo
$file
}
function
geth_attach
{
geth
"
$@
"
attach ipc:node1/geth.ipc
bfaconfig node
geth
--cache
256
"
$@
"
attach ipc:
${
BFANODEDIR
}
/geth.ipc
}
function
geth_exec_js
{
test
-r
"
$1
"
local
out
=
$(
bfamktemp
)
geth_attach
--exec
"loadScript(
\"
$1
\"
)"
>
$out
echo
$out
geth_attach
--exec
"loadScript(
\"
$1
\"
)"
}
function
getnetworkid
...
...
@@ -126,6 +117,12 @@ function nodedir
fatal
"
$BFANODEDIR
is not a directory."
test
-d
"
${
BFANODEDIR
}
/geth/chaindata"
||
fatal
"Node is not initialised. Consider running: geth --datadir
$BFANODEDIR
init
${
BFANETWORKDIR
}
/genesis.json"
# Support migrating from "former" setups
if
[
-r
"
${
BFANODEDIR
}
/port"
-a
!
-r
"
${
BFANODEDIR
}
/netport"
]
then
mv
"
${
BFANODEDIR
}
/port"
"
${
BFANODEDIR
}
/netport"
fi
#
test
-r
"
${
BFANODEDIR
}
/netport"
||
echo
$((
$RANDOM
/
2
+
12345
))
>
${
BFANODEDIR
}
/netport
netport
=
$(
cat
${
BFANODEDIR
}
/netport
)
...
...
@@ -133,6 +130,10 @@ function nodedir
test
-r
"
${
BFANODEDIR
}
/rpcport"
||
echo
$((
$RANDOM
/
2
+
12345
))
>
${
BFANODEDIR
}
/rpcport
rpcport
=
$(
cat
${
BFANODEDIR
}
/rpcport
)
# something uniqueish
local
iphash
=
$(
ip addr show scope global |
awk
'/^ *inet /{print $2}'
|
sed
's,/.*,,'
|
sha256sum
)
BFAEXTRADATA
=
"
${
USER
}
@
${
HOSTNAME
}
${
iphash
}
"
BFAEXTRADATA
=
"
${
BFAEXTRADATA
:0:32
}
"
}
function
account
...
...
This diff is collapsed.
Click to expand it.
bin/start.sh
+
6
−
0
View file @
1fb9fecc
...
...
@@ -84,6 +84,12 @@ bfaconfig max
--syncmode
full
\
--nousb
\
--bootnodes
"
${
bootnodes
}
"
\
--txpool
.nolocals
\
--txpool
.accountslots 128
\
--txpool
.globalslots 32768
\
--txpool
.accountqueue 512
\
--txpool
.globalqueue 8192
\
--extradata
"
${
BFAEXTRADATA
}
"
\
--gcmode
archive
\
--cache
512
\
--verbosity
3
...
...
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