Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
node/approval-voting: Address final comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lldenaurois committed Jul 8, 2021
1 parent 6b0f048 commit 4e8dde8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 13 deletions.
5 changes: 5 additions & 0 deletions node/core/approval-voting/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

//! An abstraction over storage used by the chain selection subsystem.
//!
//! This provides both a [`Backend`] trait and an [`OverlayedBackend`]
//! struct which allows in-memory changes to be applied on top of a
//! [`Backend`], maintaining consistency between queries and temporary writes,
//! before any commit to the underlying storage is made.
use polkadot_node_subsystem::{SubsystemResult};
use polkadot_primitives::v1::{BlockNumber, CandidateHash, Hash};
Expand Down
14 changes: 7 additions & 7 deletions node/core/approval-voting/src/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ pub fn add_block_entry(

candidate_entry.block_assignments.insert(
entry.block_hash(),
ApprovalEntry {
tranches: Vec::new(),
ApprovalEntry::new(
Vec::new(),
backing_group,
our_assignment: our_assignment.map(|v| v.into()),
our_approval_sig: None,
assignments: bitvec::bitvec![BitOrderLsb0, u8; 0; n_validators],
approved: false,
}
our_assignment.map(|v| v.into()),
None,
bitvec::bitvec![BitOrderLsb0, u8; 0; n_validators],
false,
)
);

store.write_candidate_entry(candidate_entry.clone());
Expand Down
25 changes: 19 additions & 6 deletions node/core/approval-voting/src/persisted_entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,29 @@ impl From<TrancheEntry> for crate::approval_db::v1::TrancheEntry {
/// particular block.
#[derive(Debug, Clone, PartialEq)]
pub struct ApprovalEntry {
pub tranches: Vec<TrancheEntry>,
pub backing_group: GroupIndex,
pub our_assignment: Option<OurAssignment>,
pub our_approval_sig: Option<ValidatorSignature>,
tranches: Vec<TrancheEntry>,
backing_group: GroupIndex,
our_assignment: Option<OurAssignment>,
our_approval_sig: Option<ValidatorSignature>,
// `n_validators` bits.
pub assignments: BitVec<BitOrderLsb0, u8>,
pub approved: bool,
assignments: BitVec<BitOrderLsb0, u8>,
approved: bool,
}

impl ApprovalEntry {
/// Convenience constructor
pub fn new(
tranches: Vec<TrancheEntry>,
backing_group: GroupIndex,
our_assignment: Option<OurAssignment>,
our_approval_sig: Option<ValidatorSignature>,
// `n_validators` bits.
assignments: BitVec<BitOrderLsb0, u8>,
approved: bool,
) -> Self {
Self { tranches, backing_group, our_assignment, our_approval_sig, assignments, approved }
}

// Access our assignment for this approval entry.
pub fn our_assignment(&self) -> Option<&OurAssignment> {
self.our_assignment.as_ref()
Expand Down

0 comments on commit 4e8dde8

Please sign in to comment.