Struct ckb_proposal_table::ProposalTable
source · [−]pub struct ProposalTable { /* private fields */ }
Expand description
A Table record proposals set in number-ids pairs
Implementations
sourceimpl 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
sourceimpl Clone for ProposalTable
impl Clone for ProposalTable
sourcefn clone(&self) -> ProposalTable
fn clone(&self) -> ProposalTable
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ProposalTable
impl Debug for ProposalTable
sourceimpl PartialEq<ProposalTable> for ProposalTable
impl PartialEq<ProposalTable> for ProposalTable
sourcefn 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 ==
. Read more
sourcefn ne(&self, other: &ProposalTable) -> bool
fn ne(&self, other: &ProposalTable) -> bool
This method tests for !=
.
impl Eq for ProposalTable
impl StructuralEq for ProposalTable
impl StructuralPartialEq for ProposalTable
Auto Trait Implementations
impl RefUnwindSafe for ProposalTable
impl Send for ProposalTable
impl Sync for ProposalTable
impl Unpin for ProposalTable
impl UnwindSafe for ProposalTable
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more