Remove shared_secrets from Process
This commit is contained in:
parent
d275fc5bc0
commit
b2ad5ee227
@ -137,53 +137,24 @@ impl ProcessState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// A process is basically a succession of states
|
/// A process is basically a succession of states
|
||||||
/// If a process has nothing to do with us, shared_secrets and impending_requests will be empty
|
/// If a process has nothing to do with us, impending_requests will be empty
|
||||||
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
|
||||||
pub struct Process {
|
pub struct Process {
|
||||||
states: Vec<ProcessState>,
|
states: Vec<ProcessState>,
|
||||||
shared_secrets: HashMap<String, AnkSharedSecretHash>,
|
|
||||||
impending_requests: Vec<Prd>,
|
impending_requests: Vec<Prd>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Process {
|
impl Process {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
states: Vec<ProcessState>,
|
states: Vec<ProcessState>,
|
||||||
shared_secrets: HashMap<SilentPaymentAddress, AnkSharedSecretHash>,
|
|
||||||
impending_requests: Vec<Prd>,
|
impending_requests: Vec<Prd>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
states,
|
states,
|
||||||
shared_secrets: shared_secrets
|
|
||||||
.into_iter()
|
|
||||||
.map(|(k, v)| (k.to_string(), v))
|
|
||||||
.collect(),
|
|
||||||
impending_requests,
|
impending_requests,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_shared_secret(
|
|
||||||
&mut self,
|
|
||||||
address: SilentPaymentAddress,
|
|
||||||
secret: AnkSharedSecretHash,
|
|
||||||
) {
|
|
||||||
self.shared_secrets.insert(address.to_string(), secret);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_shared_secret_for_address(
|
|
||||||
&self,
|
|
||||||
address: &SilentPaymentAddress,
|
|
||||||
) -> Option<AnkSharedSecretHash> {
|
|
||||||
self.shared_secrets.get(&address.to_string()).cloned()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn get_all_secrets(&self) -> HashMap<SilentPaymentAddress, AnkSharedSecretHash> {
|
|
||||||
self.shared_secrets
|
|
||||||
.clone()
|
|
||||||
.into_iter()
|
|
||||||
.map(|(k, v)| (SilentPaymentAddress::try_from(k.as_str()).unwrap(), v))
|
|
||||||
.collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn insert_state(&mut self, state: ProcessState) {
|
pub fn insert_state(&mut self, state: ProcessState) {
|
||||||
self.states.push(state);
|
self.states.push(state);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user