Struct data_chain::data_chain::DataChain
[−]
[src]
pub struct DataChain { /* fields omitted */ }
Created by holder of chain, can be passed to others as proof of data held. This object is verifiable if : The last validation contains the majority of current close group OR on network restart the nodes all must try and restart on previous names. They can continue any validation of the holder of a chain. This requires nodes to always restart as last ID and if there was no restart they are rejected at vault level. If there was a restart then the nodes should validate and continue. N:B this means all nodes can use a named directory for data store and clear if they restart as a new id. This allows clean-up of old data cache directories.
Methods
impl DataChain
[src]
pub fn validate_ownership(&mut self, my_group: &[PublicKey]) -> bool
[src]
Nodes always validate a chain before accepting it Validation takes place from start of chain to now. Also confirm we can accept this chain, by comparing our current group with the majority of the last known link This method will NOT purge
pub fn add_node_block(&mut self, block: NodeBlock) -> Option<BlockIdentifier>
[src]
Add a nodeblock received from a peer
Uses lazy accumulation
If block becomes or is valid, then it is returned
pub fn find(&self, block_identifier: &BlockIdentifier) -> Option<&Block>
[src]
find a block (user required to test for validity)
pub fn as_slice(&self) -> &[Block]
[src]
Extract slice containing entire chain
pub fn as_mut_slice(&mut self) -> &[Block]
[src]
Extract mutable slice containing entire chain
pub fn remove(&mut self, data_id: &BlockIdentifier)
[src]
Remove a block, will ignore Links
pub fn clear(&mut self)
[src]
Clear chain
pub fn contains(&self, block_identifier: &BlockIdentifier) -> bool
[src]
Check if chain contains a particular identifier
pub fn position(&self, block_identifier: &BlockIdentifier) -> Option<usize>
[src]
Return position of block identifier
pub fn insert(&mut self, index: usize, block: Block)
[src]
Inserts an element at position index within the chain, shifting all elements after it to the right. Will not validate this block!
Panics
Panics if index is greater than the chains's length.
pub fn split<F>(&self, pred: F) -> Split<Block, F> where
F: FnMut(&Block) -> bool,
[src]
F: FnMut(&Block) -> bool,
Returns an iterator over subslices separated by elements that match pred. The matched element is not contained in the subslices.
pub fn split_mut<F>(&mut self, pred: F) -> SplitMut<Block, F> where
F: FnMut(&Block) -> bool,
[src]
F: FnMut(&Block) -> bool,
Returns an iterator over subslices separated by elements that match pred. The matched element is not contained in the subslices.
pub fn splitn<F>(&self, n: usize, pred: F) -> SplitN<Block, F> where
F: FnMut(&Block) -> bool,
[src]
F: FnMut(&Block) -> bool,
Returns an iterator over subslices separated by elements that match pred, limited to returning at most n items. The matched element is not contained in the subslices. The last element returned, if any, will contain the remainder of the slice.
pub fn splitn_mut<F>(&mut self, n: usize, pred: F) -> SplitNMut<Block, F> where
F: FnMut(&Block) -> bool,
[src]
F: FnMut(&Block) -> bool,
Returns an iterator over subslices separated by elements that match pred, limited to returning at most n items. The matched element is not contained in the subslices. The last element returned, if any, will contain the remainder of the slice.
pub fn split_off(&mut self, at: usize) -> Vec<Block>
[src]
Splits the chain into two at the given index. Returns a newly allocated Self. chain contains elements [0, at), and the returned chain contains elements [at, len). Note that the capacity of chain does not change.]]
pub fn rsplitn<F>(&self, n: usize, pred: F) -> RSplitN<Block, F> where
F: FnMut(&Block) -> bool,
[src]
F: FnMut(&Block) -> bool,
Returns an iterator over subslices separated by elements that match pred limited to returning at most n items. This starts at the end of the slice and works backwards. The matched element is not contained in the subslices. The last element returned, if any, will contain the remainder of the slice.
pub fn rsplitn_mut<F>(&mut self, n: usize, pred: F) -> RSplitNMut<Block, F> where
F: FnMut(&Block) -> bool,
[src]
F: FnMut(&Block) -> bool,
Returns an iterator over subslices separated by elements that match pred limited to returning at most n items. This starts at the end of the slice and works backwards. The matched element is not contained in the subslices. The last element returned, if any, will contain the remainder of the slice.
pub fn validate_block(&mut self, block: &mut Block) -> bool
[src]
Validate an individual block. Will get latest link and confirm all signatures were from last known valid group.
pub fn prune(&mut self)
[src]
Remove all invalid blocks, does not confirm chain is valid to this group.
pub fn len(&self) -> usize
[src]
Total length of chain
pub fn valid_len(&self) -> usize
[src]
Number of valid blocks
pub fn blocks_len(&self) -> usize
[src]
number of blocks
pub fn links_len(&self) -> usize
[src]
number of links
pub fn is_empty(&self) -> bool
[src]
Contains no blocks that are not valid
pub fn get_all_links(&self) -> DataChain
[src]
Return all links in chain Does not perform validation on links
pub fn get_all_valid_links(&mut self) -> DataChain
[src]
Validate and return all links in chain
pub fn mark_blocks_valid(&mut self)
[src]
Mark all links that are valid as such.
Trait Implementations
impl Default for DataChain
[src]
impl Debug for DataChain
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl PartialEq for DataChain
[src]
fn eq(&self, __arg_0: &DataChain) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &DataChain) -> bool
[src]
This method tests for !=
.
impl Encodable for DataChain
[src]
fn encode<__S: Encoder>(&self, __arg_0: &mut __S) -> Result<(), __S::Error>
[src]
Serialize a value using an Encoder
.