pub struct ProposalTable { /* private fields */ }
Expand description
A Table record proposals set in number-ids pairs
Implementations§
Source§impl ProposalTable
impl ProposalTable
Sourcepub fn new(proposal_window: ProposalWindow) -> Self
pub fn new(proposal_window: ProposalWindow) -> Self
Create new ProposalTable from ProposalWindow
Sourcepub fn insert(
&mut self,
number: BlockNumber,
ids: HashSet<ProposalShortId>,
) -> bool
pub fn insert( &mut self, number: BlockNumber, ids: HashSet<ProposalShortId>, ) -> bool
Inserts a number-ids pair into the table. If the TABLE did not have this number present, true is returned. If the map did have this number present, the proposal set is updated.
Sourcepub fn remove(
&mut self,
number: BlockNumber,
) -> Option<HashSet<ProposalShortId>>
pub fn remove( &mut self, number: BlockNumber, ) -> Option<HashSet<ProposalShortId>>
Removes a proposal set from the table, returning the set at the number if the number was previously in the table
§Examples
use ckb_chain_spec::consensus::ProposalWindow;
use ckb_proposal_table::ProposalTable;
let window = ProposalWindow(2, 10);
let mut table = ProposalTable::new(window);
assert_eq!(table.remove(1), None);
Sourcepub fn all(&self) -> &BTreeMap<BlockNumber, HashSet<ProposalShortId>>
pub fn all(&self) -> &BTreeMap<BlockNumber, HashSet<ProposalShortId>>
Return referent of internal BTreeMap contains all proposal set
Sourcepub fn finalize(
&mut self,
origin: &ProposalView,
number: BlockNumber,
) -> (HashSet<ProposalShortId>, ProposalView)
pub fn finalize( &mut self, origin: &ProposalView, number: BlockNumber, ) -> (HashSet<ProposalShortId>, ProposalView)
Update table by proposal window move forward, drop outdated proposal set Return removed proposal ids set and new ProposalView
Trait Implementations§
Source§impl Clone for ProposalTable
impl Clone for ProposalTable
Source§fn clone(&self) -> ProposalTable
fn clone(&self) -> ProposalTable
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for ProposalTable
impl Debug for ProposalTable
Source§impl PartialEq for ProposalTable
impl PartialEq for ProposalTable
impl Eq for ProposalTable
impl StructuralPartialEq for ProposalTable
Auto Trait Implementations§
impl Freeze for ProposalTable
impl RefUnwindSafe for ProposalTable
impl Send for ProposalTable
impl Sync for ProposalTable
impl Unpin for ProposalTable
impl UnwindSafe for ProposalTable
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more