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
25b25a0b
Commit
25b25a0b
authored
5 years ago
by
Wei Tang
Browse files
Options
Downloads
Patches
Plain Diff
beacon: indexed_attestation and attesting_indices
parent
86c4fe88
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
beacon/src/executive/helpers/accessors.rs
+39
-0
39 additions, 0 deletions
beacon/src/executive/helpers/accessors.rs
with
39 additions
and
0 deletions
beacon/src/executive/helpers/accessors.rs
+
39
−
0
View file @
25b25a0b
...
...
@@ -209,4 +209,43 @@ impl<C: Config> BeaconState<C> {
utils
::
bls_domain
(
domain_type
,
fork_version
)
}
pub
fn
indexed_attestation
(
&
self
,
attestation
:
Attestation
<
C
>
)
->
Result
<
IndexedAttestation
<
C
>
,
Error
>
{
let
attesting_indices
=
self
.attesting_indices
(
&
attestation
.data
,
&
attestation
.aggregation_bits
)
?
;
let
custody_bit_1_indices
=
self
.attesting_indices
(
&
attestation
.data
,
&
attestation
.custody_bits
)
?
;
let
custody_bit_0_indices
=
attesting_indices
.clone
()
.into_iter
()
.filter
(|
index
|
!
custody_bit_1_indices
.contains
(
index
))
.collect
::
<
Vec
<
_
>>
();
Ok
(
IndexedAttestation
{
data
:
attestation
.data
,
signature
:
attestation
.signature
,
custody_bit_0_indices
:
custody_bit_0_indices
.into
(),
custody_bit_1_indices
:
custody_bit_1_indices
.into
(),
})
}
pub
fn
attesting_indices
(
&
self
,
attestation_data
:
&
AttestationData
,
bitfield
:
&
[
bool
],
)
->
Result
<
Vec
<
ValidatorIndex
>
,
Error
>
{
let
committee
=
self
.crosslink_committee
(
attestation_data
.target.epoch
,
attestation_data
.crosslink.shard
)
?
;
let
mut
ret
=
committee
.into_iter
()
.enumerate
()
.filter
(|(
i
,
_
)|
bitfield
[
*
i
])
.map
(|(
_
,
val
)|
val
)
.collect
::
<
Vec
<
_
>>
();
ret
.sort
();
Ok
(
ret
)
}
}
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