Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
shasper
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Insights
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
parity
shasper
Commits
86c4fe88
Commit
86c4fe88
authored
5 years ago
by
Wei Tang
Browse files
Options
Downloads
Patches
Plain Diff
beacon: total_balance and total_active_balance
parent
deeae6a4
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
beacon/src/executive/helpers/accessors.rs
+14
-1
14 additions, 1 deletion
beacon/src/executive/helpers/accessors.rs
beacon/src/primitives/mod.rs
+1
-0
1 addition, 0 deletions
beacon/src/primitives/mod.rs
with
15 additions
and
1 deletion
beacon/src/executive/helpers/accessors.rs
+
14
−
1
View file @
86c4fe88
...
...
@@ -179,13 +179,26 @@ impl<C: Config> BeaconState<C> {
let
compact_balance
=
validator
.effective_balance
/
C
::
effective_balance_increment
();
let
compact_validator
=
(
index
<<
16
)
+
(
if
validator
.slashed
{
1
}
else
{
0
}
<<
15
)
+
compact_balance
;
committees
[
shard
as
usize
]
.compact_validators
.
append
(
compact_validator
);
committees
[
shard
as
usize
]
.compact_validators
.
push
(
compact_validator
);
}
}
Ok
(
tree_root
::
<
C
::
Digest
,
_
>
(
&
committees
))
}
pub
fn
total_balance
(
&
self
,
indices
:
&
[
ValidatorIndex
])
->
Gwei
{
max
(
indices
.iter
()
.fold
(
0
,
|
sum
,
index
|
{
sum
+
self
.validators
[
*
index
as
usize
]
.effective_balance
}),
1
)
}
pub
fn
total_active_balance
(
&
self
)
->
Gwei
{
self
.total_balance
(
&
self
.active_validator_indices
(
self
.current_epoch
()))
}
pub
fn
domain
(
&
self
,
domain_type
:
Uint
,
message_epoch
:
Option
<
Uint
>
)
->
Uint
{
let
epoch
=
message_epoch
.unwrap_or
(
self
.current_epoch
());
let
fork_version
=
if
epoch
<
self
.fork.epoch
{
...
...
This diff is collapsed.
Click to expand it.
beacon/src/primitives/mod.rs
+
1
−
0
View file @
86c4fe88
...
...
@@ -27,3 +27,4 @@ pub type Epoch = Uint;
pub
type
Slot
=
Uint
;
pub
type
ValidatorIndex
=
Uint
;
pub
type
Shard
=
Uint
;
pub
type
Gwei
=
Uint
;
This diff is collapsed.
Click to expand it.
Preview
0%
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