Struct routing::PrivAppendableData
[−]
[src]
pub struct PrivAppendableData { pub name: XorName, pub version: u64, pub current_owner_keys: Vec<PublicKey>, pub previous_owner_keys: Vec<PublicKey>, pub filter: Filter, pub encrypt_key: PublicKey, pub deleted_data: BTreeSet<PrivAppendedData>, pub previous_owner_signatures: Vec<Signature>, pub data: BTreeSet<PrivAppendedData>, }
Private appendable data.
These types may be stored unsigned with previous and current owner keys set to the same keys. Updates require a signature to validate.
Data can be appended by any key that is not excluded by the filter.
Fields
name: XorName
The name of this data chunk.
version: u64
The version, i.e. the number of times this has been updated by a Post
request.
current_owner_keys: Vec<PublicKey>
The keys of the current owners that have the right to modify this data.
previous_owner_keys: Vec<PublicKey>
The keys of the owners of the chunk's previous version.
filter: Filter
The filter defining who is allowed to append items.
encrypt_key: PublicKey
The key to use for encrypting appended data items.
deleted_data: BTreeSet<PrivAppendedData>
A collection of previously deleted data items.
previous_owner_signatures: Vec<Signature>
The signatures of the above fields by the previous owners, confirming the last update.
data: BTreeSet<PrivAppendedData>
The collection of appended data items. These are not signed by the owners, as they change
even between Post
s.
Methods
impl PrivAppendableData
[src]
fn new(name: XorName,
version: u64,
current_owner_keys: Vec<PublicKey>,
previous_owner_keys: Vec<PublicKey>,
deleted_data: BTreeSet<PrivAppendedData>,
filter: Filter,
encrypt_key: PublicKey,
signing_key: Option<&SecretKey>)
-> Result<PrivAppendableData, RoutingError>
version: u64,
current_owner_keys: Vec<PublicKey>,
previous_owner_keys: Vec<PublicKey>,
deleted_data: BTreeSet<PrivAppendedData>,
filter: Filter,
encrypt_key: PublicKey,
signing_key: Option<&SecretKey>)
-> Result<PrivAppendableData, RoutingError>
Creates a new PubAppendableData
signed with signing_key
.
fn update_with_other(&mut self,
other: PrivAppendableData)
-> Result<(), RoutingError>
other: PrivAppendableData)
-> Result<(), RoutingError>
Updates this data item with the given updated version if the update is valid, otherwise returns an error.
This allows types to be created and previous_owner_signatures
added one by one.
To transfer ownership, the current owner signs over the data; the previous owners field
must have the previous owners of version - 1
as the current owners of that last version.
The data
will contain the union of the data items, excluding the deleted_data
as
given in the update.
fn validate_self_against_successor(&self,
other: &PrivAppendableData)
-> Result<(), RoutingError>
other: &PrivAppendableData)
-> Result<(), RoutingError>
Verifies that other
is a valid update for self
; returns an error otherwise.
An update is valid if it doesn't change the name, increases the version by 1 and is signed by (more than 50% of) the owners.
In case of an ownership transfer, the previous_owner_keys
in other
must match the
current_owner_keys
in self
.
fn append(&mut self,
priv_appended_data: PrivAppendedData,
sign_key: &PublicKey)
-> bool
priv_appended_data: PrivAppendedData,
sign_key: &PublicKey)
-> bool
Inserts the given data item, or returns false
if it cannot be added because it has
recently been deleted.
fn apply_wrapper(&mut self, wrapper: AppendWrapper) -> bool
Inserts the given wrapper item, or returns false
if cannot
fn name(&self) -> &XorName
Returns the name.
fn identifier(&self) -> DataIdentifier
Returns DataIdentifier
for this data element.
fn add_signature(&mut self,
secret_key: &SecretKey)
-> Result<usize, RoutingError>
secret_key: &SecretKey)
-> Result<usize, RoutingError>
Adds a signature with the given secret_key
to the previous_owner_signatures
and returns
the number of signatures that are still required. If more than 50% of the previous owners
have signed, 0 is returned and validation is complete.
fn replace_signatures(&mut self, new_signatures: Vec<Signature>)
Overwrite any existing signatures with the new signatures provided.
fn get_data(&self) -> &BTreeSet<PrivAppendedData>
Get the data
fn get_previous_owner_keys(&self) -> &Vec<PublicKey>
Get the previous owner keys
fn get_version(&self) -> u64
Get the version
fn get_owner_keys(&self) -> &Vec<PublicKey>
Get the current owner keys
fn get_previous_owner_signatures(&self) -> &Vec<Signature>
Get previous owner signatures
fn validate_size(&self) -> bool
Return true if the size is valid
Trait Implementations
impl Hash for PrivAppendableData
[src]
fn hash<__H: Hasher>(&self, __arg_0: &mut __H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl Eq for PrivAppendableData
[src]
impl PartialEq for PrivAppendableData
[src]
fn eq(&self, __arg_0: &PrivAppendableData) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &PrivAppendableData) -> bool
This method tests for !=
.
impl PartialOrd for PrivAppendableData
[src]
fn partial_cmp(&self, __arg_0: &PrivAppendableData) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &PrivAppendableData) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &PrivAppendableData) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &PrivAppendableData) -> bool
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &PrivAppendableData) -> bool
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl Ord for PrivAppendableData
[src]
fn cmp(&self, __arg_0: &PrivAppendableData) -> Ordering
This method returns an Ordering
between self
and other
. Read more
impl Clone for PrivAppendableData
[src]
fn clone(&self) -> PrivAppendableData
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Decodable for PrivAppendableData
[src]
fn decode<__D: Decoder>(__arg_0: &mut __D)
-> Result<PrivAppendableData, __D::Error>
-> Result<PrivAppendableData, __D::Error>