Skip to content
This repository has been archived by the owner on Jun 25, 2021. It is now read-only.

Commit

Permalink
Merge e2c6f97 into 160451e
Browse files Browse the repository at this point in the history
  • Loading branch information
maqi committed Jun 10, 2021
2 parents 160451e + e2c6f97 commit ffe50a8
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
12 changes: 6 additions & 6 deletions src/node/agreement.rs
Expand Up @@ -6,7 +6,7 @@
// KIND, either express or implied. Please review the Licences for the specific language governing
// permissions and limitations relating to use of the SAFE Network Software.

use super::{plain_message::PlainMessage, section::MemberInfo, signed::Signed};
use super::{plain_message::PlainMessage, section::NodeOp, signed::Signed};
use crate::SectionAuthorityProvider;
use ed25519_dalek::{PublicKey, Signature};
use hex_fmt::HexFmt;
Expand Down Expand Up @@ -50,12 +50,12 @@ pub struct DkgFailureSignedSet {

/// A value together with the signed that it was agreed on by the majority of the section elders.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Serialize, Deserialize)]
pub struct Proven<T: Serialize> {
pub struct SectionSigned<T: Serialize> {
pub value: T,
pub signed: Signed,
}

impl<T> Borrow<Prefix> for Proven<T>
impl<T> Borrow<Prefix> for SectionSigned<T>
where
T: Borrow<Prefix> + Serialize,
{
Expand All @@ -69,15 +69,15 @@ where
pub enum Proposal {
// Proposal to add a node to oursection
Online {
member_info: MemberInfo,
node_op: NodeOp,
// Previous name if relocated.
previous_name: Option<XorName>,
// The key of the destination section that the joining node knows, if any.
destination_key: Option<BlsPublicKey>,
},

// Proposal to remove a node from our section
Offline(MemberInfo),
Offline(NodeOp),

// Proposal to update info about a section. This has two purposes:
//
Expand All @@ -97,7 +97,7 @@ pub enum Proposal {
// 4. the signature of the new key using the current key
// Which we can use to update the section section authority provider and the section chain at
// the same time as a single atomic operation without needing to cache anything.
OurElders(Proven<SectionAuthorityProvider>),
OurElders(SectionSigned<SectionAuthorityProvider>),

// Proposal to accumulate the message at the source (that is, our section) and then send it to
// its destination.
Expand Down
10 changes: 5 additions & 5 deletions src/node/join.rs
Expand Up @@ -6,7 +6,7 @@
// KIND, either express or implied. Please review the Licences for the specific language governing
// permissions and limitations relating to use of the SAFE Network Software.

use super::{agreement::Proven, relocation::RelocatePayload, section::MemberInfo};
use super::{agreement::SectionSigned, relocation::RelocatePayload, section::NodeOp};
use crate::SectionAuthorityProvider;
use ed25519_dalek::Signature;
use secured_linked_list::SecuredLinkedList;
Expand Down Expand Up @@ -81,8 +81,8 @@ pub enum JoinResponse {
/// info to become a member of the section.
Approval {
genesis_key: BlsPublicKey,
section_auth: Proven<SectionAuthorityProvider>,
member_info: Proven<MemberInfo>,
section_auth: SectionSigned<SectionAuthorityProvider>,
node_op: SectionSigned<NodeOp>,
section_chain: SecuredLinkedList,
},
Rejected(JoinRejectionReason),
Expand All @@ -105,13 +105,13 @@ impl Debug for JoinResponse {
Self::Approval {
genesis_key,
section_auth,
member_info,
node_op,
section_chain,
} => f
.debug_struct("Approval")
.field("genesis_key", genesis_key)
.field("section_auth", section_auth)
.field("member_info", member_info)
.field("node_op", node_op)
.field("section_chain", section_chain)
.finish(),
Self::Rejected(reason) => write!(f, "Rejected({:?})", reason),
Expand Down
4 changes: 2 additions & 2 deletions src/node/mod.rs
Expand Up @@ -20,7 +20,7 @@ mod signed;
mod src_authority;
mod variant;

pub use agreement::{DkgFailureSigned, DkgFailureSignedSet, DkgKey, Proposal, Proven};
pub use agreement::{DkgFailureSigned, DkgFailureSignedSet, DkgKey, Proposal, SectionSigned};
pub use join::{JoinRejectionReason, JoinRequest, JoinResponse, ResourceProofResponse};
pub use network::{Network, OtherSection};
pub use node_msg::{
Expand All @@ -31,7 +31,7 @@ pub use node_msg::{
pub use plain_message::PlainMessage;
pub use prefix_map::PrefixMap;
pub use relocation::{RelocateDetails, RelocatePayload, RelocatePromise, SignedRelocateDetails};
pub use section::{ElderCandidates, MemberInfo, Peer, PeerState, Section, SectionPeers};
pub use section::{ElderCandidates, NodeOp, Peer, PeerState, Section, SectionPeers};
pub use signature_aggregator::{Error, SignatureAggregator};
pub use signed::{Signed, SignedShare};
pub use src_authority::SrcAuthority;
Expand Down
4 changes: 2 additions & 2 deletions src/node/network.rs
Expand Up @@ -6,7 +6,7 @@
// KIND, either express or implied. Please review the Licences for the specific language governing
// permissions and limitations relating to use of the SAFE Network Software.

use super::{agreement::Proven, prefix_map::PrefixMap, signed::Signed};
use super::{agreement::SectionSigned, prefix_map::PrefixMap, signed::Signed};
use crate::SectionAuthorityProvider;
use serde::{Deserialize, Serialize};
use std::borrow::Borrow;
Expand All @@ -24,7 +24,7 @@ pub struct OtherSection {
// If this is signed by our section, then `key_signed` is `None`. If this is signed by our
// sibling section, then `key_signed` contains the proof of the signing key itself signed by our
// section.
pub section_auth: Proven<SectionAuthorityProvider>,
pub section_auth: SectionSigned<SectionAuthorityProvider>,
pub key_signed: Option<Signed>,
}

Expand Down
14 changes: 7 additions & 7 deletions src/node/section/mod.rs
Expand Up @@ -7,14 +7,14 @@
// permissions and limitations relating to use of the SAFE Network Software.

mod candidates;
mod member_info;
mod node_op;
mod peer;

pub use candidates::ElderCandidates;
pub use member_info::{MemberInfo, PeerState};
pub use node_op::{NodeOp, PeerState};
pub use peer::Peer;

use crate::{node::agreement::Proven, SectionAuthorityProvider};
use crate::{node::agreement::SectionSigned, SectionAuthorityProvider};
use secured_linked_list::SecuredLinkedList;
use serde::{Deserialize, Serialize};
use std::{
Expand All @@ -28,14 +28,14 @@ use xor_name::XorName;
pub struct Section {
pub genesis_key: BlsPublicKey,
pub chain: SecuredLinkedList,
pub section_auth: Proven<SectionAuthorityProvider>,
pub section_auth: SectionSigned<SectionAuthorityProvider>,
pub members: SectionPeers,
}

/// Container for storing information about members of our section.
#[derive(Clone, Default, Debug, Eq, Serialize, Deserialize)]
pub struct SectionPeers {
pub members: BTreeMap<XorName, Proven<MemberInfo>>,
pub members: BTreeMap<XorName, SectionSigned<NodeOp>>,
}

impl PartialEq for SectionPeers {
Expand All @@ -50,10 +50,10 @@ impl Hash for SectionPeers {
}
}

pub struct IntoIter(btree_map::IntoIter<XorName, Proven<MemberInfo>>);
pub struct IntoIter(btree_map::IntoIter<XorName, SectionSigned<NodeOp>>);

impl Iterator for IntoIter {
type Item = Proven<MemberInfo>;
type Item = SectionSigned<NodeOp>;

fn next(&mut self) -> Option<Self::Item> {
self.0.next().map(|(_, info)| info)
Expand Down
Expand Up @@ -12,7 +12,7 @@ use xor_name::XorName;

/// Information about a member of our section.
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize, Debug)]
pub struct MemberInfo {
pub struct NodeOp {
pub peer: Peer,
pub state: PeerState,
}
Expand Down
4 changes: 2 additions & 2 deletions src/node/variant.rs
Expand Up @@ -7,7 +7,7 @@
// permissions and limitations relating to use of the SAFE Network Software.

use super::{
agreement::{DkgFailureSigned, DkgFailureSignedSet, DkgKey, Proposal, Proven},
agreement::{DkgFailureSigned, DkgFailureSignedSet, DkgKey, Proposal, SectionSigned},
join::{JoinRequest, JoinResponse},
network::Network,
relocation::{RelocateDetails, RelocatePromise},
Expand Down Expand Up @@ -35,7 +35,7 @@ pub enum Variant {
/// Inform other sections about our section or vice-versa.
SectionKnowledge {
/// `SectionAuthorityProvider` and `SecuredLinkedList` of the sender's section, with the proof chain.
src_info: (Proven<SectionAuthorityProvider>, SecuredLinkedList),
src_info: (SectionSigned<SectionAuthorityProvider>, SecuredLinkedList),
/// Message
msg: Option<Box<RoutingMsg>>,
},
Expand Down

0 comments on commit ffe50a8

Please sign in to comment.