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

Commit

Permalink
Merge 1fb5d72 into 0210c7b
Browse files Browse the repository at this point in the history
  • Loading branch information
oetyng committed Mar 30, 2021
2 parents 0210c7b + 1fb5d72 commit 1af6aed
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 104 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ rand_core = "~0.5.1"
rmp-serde = "~0.15.1"
serde_bytes = "0.11.5"
signature = "1.1.0"
sn_data_types = "~0.17.0"
sn_data_types = "~0.18.0"
thiserror = "1.0.23"
threshold_crypto = "~0.4.0"
xor_name = "1.1.10"
Expand Down
6 changes: 3 additions & 3 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ pub use self::{
map::{MapRead, MapWrite},
network::{
NodeCmd, NodeCmdError, NodeDataError, NodeDataQueryResponse, NodeEvent, NodeQuery,
NodeQueryResponse, NodeRewardError, NodeRewardQuery, NodeRewardQueryResponse,
NodeSystemCmd, NodeSystemQuery, NodeSystemQueryResponse, NodeTransferCmd,
NodeTransferError, NodeTransferQuery, NodeTransferQueryResponse,
NodeQueryResponse, NodeRewardQuery, NodeSystemCmd, NodeSystemQuery,
NodeSystemQueryResponse, NodeTransferCmd, NodeTransferError, NodeTransferQuery,
NodeTransferQueryResponse,
},
query::Query,
sender::{Address, MsgSender, TransientElderKey, TransientSectionKey},
Expand Down
106 changes: 8 additions & 98 deletions src/client/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ use crate::{
};
use serde::{Deserialize, Serialize};
use sn_data_types::{
ActorHistory, Blob, BlobAddress, Credit, CreditAgreementProof, DebitId, NodeRewardStage,
PublicKey, ReplicaEvent, SectionElders, Signature, SignatureShare, SignedCredit,
SignedTransferShare, TransferAgreementProof, TransferValidated, WalletHistory,
ActorHistory, Blob, BlobAddress, CreditAgreementProof, PublicKey, ReplicaEvent, SectionElders,
Signature,
};
use std::collections::{BTreeMap, BTreeSet};
use xor_name::XorName;
Expand All @@ -42,22 +41,6 @@ pub enum NodeCmd {
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
pub enum NodeSystemCmd {
/// When threshold Elders have been reached
/// in genesis section, they all propose genesis.
ProposeGenesis {
/// The genesis credit.
credit: Credit,
/// An individual Elder's sig share.
sig: SignatureShare,
},
/// When proposal has been agreed
/// in genesis section, they all accumulate genesis.
AccumulateGenesis {
/// The genesis credit.
signed_credit: SignedCredit,
/// An individual Elder's sig share.
sig: SignatureShare,
},
/// Register a wallet for reward payouts.
RegisterWallet(PublicKey),
/// Notify Elders on nearing max capacity
Expand All @@ -76,25 +59,15 @@ pub enum NodeSystemCmd {
/// Current holders.
current_holders: BTreeSet<XorName>,
},
/// When new section key, all propose new wallet.
ProposeNewWallet {
/// The genesis credit.
credit: Credit,
/// An individual Elder's sig share.
sig: SignatureShare,
},
/// When proposal has been agreed, they all accumulate the wallet.
AccumulateNewWallet {
/// The genesis credit.
signed_credit: SignedCredit,
/// An individual Elder's sig share.
sig: SignatureShare,
},
/// When new section key, all propose a reward payout.
ProposeRewardPayout(sn_data_types::RewardProposal),
/// When proposal has been agreed, they all accumulate the reward payout.
AccumulateRewardPayout(sn_data_types::RewardAccumulation),
/// Sent to all promoted nodes (also sibling if any) after
/// a completed transition to a new constellation.
ReceiveExistingData {
/// Registered node reward wallets.
node_rewards: BTreeMap<XorName, NodeRewardStage>,
node_rewards: BTreeMap<XorName, (u8, PublicKey)>,
/// Transfer histories
user_wallets: BTreeMap<PublicKey, ActorHistory>,
},
Expand All @@ -106,10 +79,6 @@ pub enum NodeSystemCmd {
pub enum NodeTransferCmd {
///
PropagateTransfer(CreditAgreementProof),
///
ValidateSectionPayout(SignedTransferShare),
///
RegisterSectionPayout(TransferAgreementProof),
}

// -------------- Node Events --------------
Expand All @@ -128,10 +97,6 @@ pub enum NodeEvent {
/// that this is all good.
proof: Signature,
},
///
RewardPayoutValidated(TransferValidated),
/// The new section wallet.
SectionWalletCreated(WalletHistory),
}

///
Expand All @@ -156,16 +121,7 @@ pub enum NodeQuery {
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
pub enum NodeRewardQuery {
/// Sent by the new section to the
/// old section after node relocation.
GetNodeWalletId {
/// The id of the node
/// in the old section.
old_node_id: XorName,
/// The id of the node
/// in the new section.
new_node_id: XorName,
},
GetNodeWalletKey(XorName),
/// A new Section Actor share (i.e. a new Elder) needs to query
/// its peer Elders for the replicas' public key set
/// and the history of events of the section wallet.
Expand Down Expand Up @@ -213,23 +169,11 @@ pub enum NodeQueryResponse {
///
Data(NodeDataQueryResponse),
///
Rewards(NodeRewardQueryResponse),
///
Transfers(NodeTransferQueryResponse),
///
System(NodeSystemQueryResponse),
}

///
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
pub enum NodeRewardQueryResponse {
/// Returns the wallet address
/// together with the new node id,
/// that followed with the original query.
GetNodeWalletId(Result<(PublicKey, XorName)>),
}

///
#[allow(clippy::large_enum_variant)]
#[derive(Debug, Eq, PartialEq, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -257,8 +201,6 @@ pub enum NodeCmdError {
///
Data(NodeDataError),
///
Rewards(NodeRewardError),
///
Transfers(NodeTransferError),
}

Expand All @@ -279,36 +221,4 @@ pub enum NodeDataError {
pub enum NodeTransferError {
/// The error of propagation of TransferRegistered event.
TransferPropagation(Error),
/// The error of registration of a section payout.
SectionPayoutRegistration(Error),
}

///
#[derive(Debug, Hash, Eq, PartialEq, Clone, Serialize, Deserialize)]
pub enum NodeRewardError {
///
RewardClaiming {
///
wallet: PublicKey,
///
error: Error,
},
///
RewardPayoutInitiation {
///
id: DebitId,
///
wallet: PublicKey,
///
error: Error,
},
///
RewardPayoutFinalisation {
///
id: DebitId,
///
wallet: PublicKey,
///
error: Error,
},
}
12 changes: 10 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,16 @@ impl MessageType {
match self {
Self::Ping(hdr_info)
| Self::ClientMessage { hdr_info, .. }
| Self::SectionInfo { hdr_info, .. }
| Self::NodeMessage { hdr_info, .. } => {
| Self::SectionInfo { hdr_info, .. } => {
if let Some(dest) = dest {
hdr_info.dest = dest
}
if let Some(dest_pk) = dest_pk {
hdr_info.dest_section_pk = dest_pk
}
}
#[cfg(not(feature = "client-only"))]
Self::NodeMessage { hdr_info, .. } => {
if let Some(dest) = dest {
hdr_info.dest = dest
}
Expand Down

0 comments on commit 1af6aed

Please sign in to comment.