Struct ckb_proposal_table::ProposalTable
source · 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 froward, 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 copy 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
source§fn eq(&self, other: &ProposalTable) -> bool
fn eq(&self, other: &ProposalTable) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.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