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
15790c91
Commit
15790c91
authored
7 years ago
by
Robert Martin-Legene
Browse files
Options
Downloads
Patches
Plain Diff
walker.pl now detects if the local node switches to another fork
parent
97169db0
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
bin/walker.pl
+82
-34
82 additions, 34 deletions
bin/walker.pl
with
82 additions
and
34 deletions
bin/walker.pl
+
82
−
34
View file @
15790c91
...
@@ -6,7 +6,6 @@ use IO::File;
...
@@ -6,7 +6,6 @@ use IO::File;
use
Math::
BigInt
;
use
Math::
BigInt
;
use
Carp
;
use
Carp
;
$
Carp::
Verbose
=
1
;
$
Carp::
Verbose
=
1
;
my
$verbose
=
0
;
die
"
\$
BFAHOME not set. Did you source bfa/bin/env ?
\n
"
die
"
\$
BFAHOME not set. Did you source bfa/bin/env ?
\n
"
unless
exists
$ENV
{
BFAHOME
};
unless
exists
$ENV
{
BFAHOME
};
...
@@ -15,6 +14,11 @@ chdir "$ENV{BFAHOME}" or die $!;
...
@@ -15,6 +14,11 @@ chdir "$ENV{BFAHOME}" or die $!;
package
tools
;
package
tools
;
my
$rpcport
;
my
$rpcport
;
my
$ua
=
LWP::
UserAgent
->
new
;
my
$ua
=
LWP::
UserAgent
->
new
;
our
$CSI
=
"
\x1b
[
";
our
$clearEOS
=
"
${CSI}
J
";
our
$up
=
"
${CSI}
A
";
our
$red
=
"
${CSI}
41m
";
our
$normal
=
"
${CSI}
m
";
sub
new
sub
new
{
{
...
@@ -208,6 +212,12 @@ sub number
...
@@ -208,6 +212,12 @@ sub number
return
hex
(
$_
[
0
]
->
result
->
{'
number
'}
);
return
hex
(
$_
[
0
]
->
result
->
{'
number
'}
);
}
}
sub
td
{
return
if
not
exists
$_
[
0
]
->
result
->
{'
totalDifficulty
'};
return
hex
(
$_
[
0
]
->
result
->
{'
totalDifficulty
'}
);
}
sub
timestamp
sub
timestamp
{
{
return
if
not
exists
$_
[
0
]
->
result
->
{'
timestamp
'};
return
if
not
exists
$_
[
0
]
->
result
->
{'
timestamp
'};
...
@@ -232,6 +242,18 @@ sub nonce
...
@@ -232,6 +242,18 @@ sub nonce
return
lc
$_
[
0
]
->
result
->
{'
nonce
'};
return
lc
$_
[
0
]
->
result
->
{'
nonce
'};
}
}
sub
hash
{
return
if
not
exists
$_
[
0
]
->
result
->
{'
hash
'};
return
lc
$_
[
0
]
->
result
->
{'
hash
'};
}
sub
parentHash
{
return
if
not
exists
$_
[
0
]
->
result
->
{'
parentHash
'};
return
lc
$_
[
0
]
->
result
->
{'
parentHash
'};
}
sub
extradata
sub
extradata
{
{
return
if
not
exists
$_
[
0
]
->
result
->
{'
extraData
'};
return
if
not
exists
$_
[
0
]
->
result
->
{'
extraData
'};
...
@@ -326,23 +348,66 @@ sub get($;$)
...
@@ -326,23 +348,66 @@ sub get($;$)
return
$block
;
return
$block
;
}
}
package
main
;
sub
delete_cache
{
my
(
$self
)
=
@_
;
unlink
sprintf
('
cache/block.0x%x
',
$self
->
number
);
}
sub
print
{
print
scalar
(
$_
[
0
]
->
sprint
),"
\n
";
}
my
$nonce_xlate
=
{
my
$nonce_xlate
=
{
'
0x0000000000000000
'
=>
'
SEALER_REM
',
'
0x0000000000000000
'
=>
'
SEALER_REM
',
'
0xffffffffffffffff
'
=>
'
SEALER_ADD
',
'
0xffffffffffffffff
'
=>
'
SEALER_ADD
',
};
};
while
(
defined
$ARGV
[
0
]
and
$ARGV
[
0
]
=~
m/^-/
)
sub
sprint
{
{
my
$arg
=
shift
;
my
(
$self
)
=
@_
;
$verbose
=
1
if
$arg
eq
'
-v
';
my
$txt
=
'';
my
$lines
=
1
;
my
@sealers
=
$self
->
sealers
;
if
(
@sealers
)
{
$txt
=
sprintf
"
\r
${tools
::
clearEOS}
";
$txt
=
'';
for
my
$sealer
(
@sealers
)
{
$txt
.=
sprintf
"
Confirming signer at epoch: 0x%s with an ETH balance of %s
\n
",
$sealer
,
balance
->
new
->
get
(
$sealer
,
$self
->
number
);
$lines
++
;
}
}
$txt
.=
sprintf
'
%s block:%s gaslimit:%s td:%d Vanity: %s
',
tools::
gmt
(
$self
->
timestamp
),
$self
->
number
,
$self
->
gasLimit
,
$self
->
td
,
tools::
hex2string
(
$self
->
vanity
);
if
(
$self
->
miner
!~
/^0x0{40}$/o
)
{
# we have auth or drop
my
$nonce
=
$self
->
nonce
;
$nonce
=
$nonce_xlate
->
{
$nonce
}
if
exists
$nonce_xlate
->
{
$nonce
};
$txt
.=
sprintf
"
%s %s
",
$nonce
,
$self
->
miner
;
}
return
wantarray
?
(
$txt
,
$lines
)
:
$txt
;
}
}
package
main
;
$|
=
1
;
$|
=
1
;
mkdir
'
cache
';
mkdir
'
cache
';
my
$number
=
shift
||
tools::
cat
'
walker.block.last
'
||
'
earliest
';
my
$number
=
shift
||
tools::
cat
'
walker.block.last
'
||
'
earliest
';
my
$tools
=
tools
->
new
;
my
$tools
=
tools
->
new
;
my
@blks
;
my
$parent
;
while
(
1
)
while
(
1
)
{
{
...
@@ -352,34 +417,17 @@ while ( 1 )
...
@@ -352,34 +417,17 @@ while ( 1 )
$tools
->
wait
();
$tools
->
wait
();
next
;
next
;
}
}
my
$txt
=
sprintf
$parent
=
block::
get
(
$block
->
number
-
1
)
if
not
defined
$parent
and
$block
->
number
>
1
;
'
%s block:%s gaslimit:%s Vanity: %s
',
if
(
defined
$parent
and
$parent
->
hash
ne
$block
->
parentHash
)
tools::
gmt
(
$block
->
timestamp
),
$block
->
number
,
$block
->
gasLimit
,
tools::
hex2string
(
$block
->
vanity
);
if
(
$block
->
miner
!~
/^0x0{40}$/
)
{
# we have auth or drop
my
$nonce
=
$block
->
nonce
;
$nonce
=
$nonce_xlate
->
{
$nonce
}
if
exists
$nonce_xlate
->
{
$nonce
};
$txt
.=
sprintf
"
%s %s
\n
",
$nonce
,
$block
->
miner
;
}
else
{
{
my
@sealers
=
$block
->
sealers
;
printf
"
\r
${tools
::
red}
%s
${tools
::
normal}
\n
",
scalar
(
$parent
->
sprint
);
if
(
@sealers
)
(
$parent
,
$block
,
$number
)
=
(
undef
,
$parent
,
$number
-
1
);
{
$block
->
delete_cache
;
printf
"
\r
%s%c[J
\n
",
$txt
,
27
;
next
;
$txt
=
'';
for
my
$sealer
(
@sealers
)
{
printf
"
Confirming signer at epoch: 0x%s with an ETH balance of %s
\n
",
$sealer
,
balance
->
new
->
get
(
$sealer
,
$block
->
number
);
}
}
}
}
printf
"
\r
%s%c[J
",
$txt
,
27
if
$txt
ne
'';
shift
@blks
while
scalar
@blks
>
32
;
#$block->signature;
push
@blks
,
$block
;
$block
->
print
;
$number
=
$block
->
number
+
1
;
$number
=
$block
->
number
+
1
;
print
"
\n
"
if
$verbose
;
$parent
=
$block
;
}
}
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