Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nucleo
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
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
Miguel Montes
nucleo
Commits
38eefbfd
Commit
38eefbfd
authored
6 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
Unlocking feature now works. Also snuck in a few new features.
parent
0c21660d
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bin/bfaupdate.sh
+10
-0
10 additions, 0 deletions
bin/bfaupdate.sh
bin/libbfa.js
+11
-4
11 additions, 4 deletions
bin/libbfa.js
bin/monitor.js
+70
-10
70 additions, 10 deletions
bin/monitor.js
bin/start.sh
+6
-42
6 additions, 42 deletions
bin/start.sh
with
97 additions
and
56 deletions
bin/bfaupdate.sh
0 → 100644
+
10
−
0
View file @
38eefbfd
#!/bin/bash
# Robert Martin-Legene <robert@nic.ar>
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
set
-x
cd
${
BFAHOME
}
git pull
npm rebuild
This diff is collapsed.
Click to expand it.
bin/libbfa.js
+
11
−
4
View file @
38eefbfd
...
...
@@ -81,32 +81,39 @@ module.exports = class Libbfa
w3
.
eth
.
extend
({
//property: 'bfaclique',
methods
:
[{
name
:
'
g
etSigners
'
,
name
:
'
bfaG
etSigners
'
,
call
:
'
clique_getSigners
'
,
params
:
0
}]
});
w3
.
eth
.
extend
({
methods
:
[{
name
:
'
m
inerstart
'
,
name
:
'
bfaM
inerstart
'
,
call
:
'
miner_start
'
,
params
:
0
}]
});
w3
.
eth
.
extend
({
methods
:
[{
name
:
'
m
inerstop
'
,
name
:
'
bfaM
inerstop
'
,
call
:
'
miner_stop
'
,
params
:
0
}]
});
w3
.
eth
.
extend
({
methods
:
[{
name
:
'
a
dminpeers
'
,
name
:
'
bfaA
dminpeers
'
,
call
:
'
admin_peers
'
,
params
:
0
}]
});
w3
.
eth
.
personal
.
extend
({
methods
:
[{
name
:
'
bfalistWallets
'
,
call
:
'
personal_listWallets
'
,
params
:
0
}]
});
if
(
undefined
!=
process
.
env
.
BFAACCOUNT
)
{
w3
.
eth
.
defaultAccount
=
this
.
account
;
}
...
...
This diff is collapsed.
Click to expand it.
bin/monitor.js
+
70
−
10
View file @
38eefbfd
...
...
@@ -5,16 +5,15 @@
"
use strict
"
const
Libbfa
=
require
(
process
.
env
.
BFAHOME
+
'
/bin/libbfa.js
'
);
var
bfa
=
new
Libbfa
();
var
web3
=
bfa
.
newweb3
();
var
now
;
function
monitor
()
{
var
bfa
=
new
Libbfa
();
var
web3
=
bfa
.
newweb3
();
var
now
=
new
Date
();
//console.log(web3.eth);
web3
.
eth
.
adminpeers
().
then
(
function
(
nodelist
)
{
var
peers
=
[];
web3
.
eth
.
bfaAdminpeers
().
then
(
function
gotAdminPeers
(
nodelist
)
{
var
peers
=
[];
nodelist
.
forEach
(
function
(
node
)
{
if
(
typeof
(
node
.
protocols
.
eth
)
==
'
object
'
)
...
...
@@ -34,12 +33,73 @@ function monitor()
{
mode
:
0o644
}
);
},
function
(
x
)
function
failedToGetAdminPeers
(
x
)
{
console
.
log
(
x
);
process
.
exit
(
1
)
}
);
}
monitor
();
// Function to determine if our defaultAccount is allowed to seal/mine.
// It will adjust the behaviour accordingly, i.e. stop or start mining.
function
mayseal
()
{
var
me
=
web3
.
eth
.
defaultAccount
;
if
(
undefined
==
me
)
{
console
.
log
(
"
Failed to get default account information.
"
);
return
;
}
me
=
me
.
toLowerCase
();
web3
.
eth
.
isMining
().
then
(
// returns a boolean whether or not we are currently mining/sealing.
function
(
isMining
)
{
// Get a list of clique.getSigners, so we can see if we are
// in the list of authorized sealers.
web3
.
eth
.
bfaGetSigners
()
.
then
(
function
gotListOfSealers
(
x
)
{
var
lcsealers
=
x
.
map
(
name
=>
name
.
toLowerCase
()
);
var
isSigner
=
(
lcsealers
.
indexOf
(
me
)
>
-
1
);
if
(
isSigner
)
{
if
(
!
isMining
)
{
console
.
log
(
'
Started to seal.
'
);
web3
.
eth
.
bfaMinerstart
();
}
}
else
{
if
(
isMining
)
{
console
.
log
(
'
I was trying to seal, but am not authorized. Stopped trying.
'
);
web3
.
eth
.
bfaMinerstop
();
}
}
},
function
failedToGetListOfSealers
(
x
)
{
console
.
log
(
x
);
}
);
},
function
failedToGetIsMiningBool
(
x
)
{
// Probably geth is not running.
console
.
log
(
x
);
}
);
}
function
timer
()
{
now
=
new
Date
();
monitor
();
mayseal
();
}
setInterval
(
timer
,
60
*
1000
);
This diff is collapsed.
Click to expand it.
bin/start.sh
+
6
−
42
View file @
38eefbfd
...
...
@@ -14,39 +14,11 @@ enodeDGSI="59ae768ecdee632e0daceccb6f71b215392eba89230d626573f2fb4e9c0786c9a6610
bootDGSIv4
=
"enode://
${
enodeDGSI
}
@[200.108.146.100]:30301"
bootnodes
=
"
${
bootARIUv6
}
,
${
bootARIUv4
}
,
${
bootUNCv4
}
,
${
bootDGSIv4
}
"
function
accountlist
{
local
accts
=
local
filename
for
filename
in
${
BFANODEDIR
}
/keystore/
*
--
*
do
if
[
-r
"
$filename
"
-a
${#
filename
}
-ge
40
]
then
acct
=
${
filename
:
$((
${#
filename
}
-
40
))}
accts
=
"
${
accts
}
,
${
acct
}
"
fi
done
# strip leading comma
accts
=
${
accts
#,
}
if
[
${#
accts
}
-ge
40
]
then
echo
"--password /dev/null --unlock
${
accts
}
"
fi
}
# touch the "miner" file if you are authorized to mine
# If you don't want to restart after touching the file,
# you can use attach.sh and issue the command:
# miner.start()
function
getminer
{
if
[
-e
"
${
BFANODEDIR
}
/miner"
]
then
echo
"--mine"
fi
}
function
getsyncmode
{
local
syncmode
=
$(
cat
"
${
BFANODEDIR
}
/syncmode"
2>/dev/null
||
true
)
...
...
@@ -96,17 +68,9 @@ function startmonitor
echo
"A monitor is already running."
false
)
||
exit
if
[
-t
1
]
then
echo
Running monitor every 60 seconds.
fi
while
:
do
monitor.js &
echo
$!
>
$pidfile
wait
sleep
60
done
&
monitor.js &
echo
$!
>
$pidfile
wait
)
9>>
$pidfile
}
...
...
@@ -134,12 +98,11 @@ function startgeth
echo
'***'
echo
# (re)configure parameters (you never know if they changed)
flexargs
=
"
$(
accountlist
)
$(
getminer
)
$(
getsyncmode
)
--extradata
$(
extradata
)
"
flexargs
=
"
$(
getsyncmode
)
--extradata
$(
extradata
)
"
set
-x
geth
\
--datadir
${
BFANODEDIR
}
\
--networkid
${
BFANETWORKID
}
\
--bootnodes
"
${
bootnodes
}
"
\
--rpc
\
--rpcport
$rpcport
\
--rpcapi
"eth,net,web3,admin,clique,miner,personal"
\
...
...
@@ -148,7 +111,8 @@ function startgeth
--gcmode
archive
\
--cache
512
\
--verbosity
${
BFAVERBOSITY
:-
3
}
\
${
flexargs
}
&
${
flexargs
}
\
--bootnodes
"
${
bootnodes
}
"
&
set
+x
echo
$!
>
${
BFANODEDIR
}
/geth.pid
wait
...
...
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