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
5ec702e5
Commit
5ec702e5
authored
5 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
Check local computer time against NIST
parent
587434ac
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/localstate.pl
+56
-19
56 additions, 19 deletions
bin/localstate.pl
with
56 additions
and
19 deletions
bin/localstate.pl
+
56
−
19
View file @
5ec702e5
...
...
@@ -9,10 +9,15 @@ use warnings;
use
Carp
;
use
Math::
BigInt
;
use
JSON
;
use
IO::Socket::
INET
;
BEGIN
{
die
"
\$
BFAHOME not set. Did you source bfa/bin/env ?
\n
"
unless
exists
$ENV
{
BFAHOME
};
}
my
%network
=
(
47525974938
=>
'
BFA red principal [est. 2018]
',
55555000000
=>
'
BFA red de pruebas numero 2 [est. 2019]
',
);
chdir
$ENV
{
BFAHOME
}
or
die
$!
;
use
lib
$ENV
{'
BFAHOME
'}
.
'
/bin
';
use
libbfa
;
...
...
@@ -151,8 +156,49 @@ sub rpc
my
$netversion
=
rpc
(
$libbfa
,
'
net_version
'
);
if
(
$netversion
)
{
printf
"
Running on network number %s
\n
",
$netversion
;
if
(
exists
$network
{
$netversion
}
)
{
printf
"
Running on network %s (#%s)
\n
",
$network
{
$netversion
},
$netversion
;
}
else
{
printf
"
Running on network %s
\n
",
$netversion
;
}
}
### compare time
use
constant
days70y
=>
25567
;
my
$s
=
IO::Socket::
INET
->
new
(
PeerAddr
=>
"
time.nist.gov:37
",
Timeout
=>
3
,
);
if
(
defined
$s
)
{
$s
->
recv
(
my
$data
,
8
);
my
$i
=
unpack
('
N
',
$data
);
if
(
$i
>
0
)
{
# rfc868 offset (seconds from 1900-01-01 to 1970-01-01)
$i
-=
2208988800
;
printf
"
NIST time: %s
\n
",
scalar
(
localtime
(
$i
));
my
$heretime
=
time
();
printf
"
Here time: %s
\n
",
scalar
(
localtime
(
$i
));
if
(
abs
(
$i
-
$heretime
)
>
5
)
{
print
"
WHY IS YOUR CLOCK OFF?
";
}
}
}
### latest block
$result
=
rpc
(
$libbfa
,
'
eth_getBlockByNumber
',
'
"latest"
',
"
true
"
);
my
$block
=
block
->
new
(
$result
);
my
$timediff
=
time
()
-
$block
->
timestamp
;
printf
"
Our latest block number is %d. It's timestamp says %s (%s old).
\n
",
$block
->
number
,
gmt
(
$block
->
timestamp
),
nicetimedelta
(
$timediff
);
### syncing ?
my
$syncing
=
rpc
(
$libbfa
,
'
eth_syncing
'
);
if
(
$syncing
)
...
...
@@ -167,31 +213,22 @@ if ( $syncing )
}
else
{
print
"
We are currently not syncing (this is normal if you have all the blocks).
\n
";
if
(
$timediff
>
90
)
{
print
"
We are currently not syncing. WHY ARE OUR BLOCKS SO OLD?
\n
";
}
else
{
print
"
We have all the blocks and are not syncing.
\n
";
}
}
### mining ?
$result
=
rpc
(
$libbfa
,
'
eth_mining
'
);
if
(
$result
)
{
printf
"
We mine when we can.
\n
";
printf
"
We are a sealer and are configured seal.
\n
";
}
else
{
print
"
We do not seal.
\n
";
}
else
{
print
"
We do not mine.
\n
";
}
### latest block
$result
=
rpc
(
$libbfa
,
'
eth_getBlockByNumber
',
'
"latest"
',
"
true
"
);
my
$block
=
block
->
new
(
$result
);
my
$timediff
=
time
()
-
$block
->
timestamp
;
printf
"
Our latest block number is %d. It's timestamp says %s (%s old).
\n
",
$block
->
number
,
gmt
(
$block
->
timestamp
),
nicetimedelta
(
$timediff
);
print
"
WHY IS IT SO OLD?
\n
"
if
$timediff
>
90
;
# List peers
$result
=
rpc
(
$libbfa
,
'
admin_peers
'
);
...
...
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