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
|
||||
/// 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)]
|
||||
pub struct Process {
|
||||
states: Vec<ProcessState>,
|
||||
shared_secrets: HashMap<String, AnkSharedSecretHash>,
|
||||
impending_requests: Vec<Prd>,
|
||||
}
|
||||
|
||||
impl Process {
|
||||
pub fn new(
|
||||
states: Vec<ProcessState>,
|
||||
shared_secrets: HashMap<SilentPaymentAddress, AnkSharedSecretHash>,
|
||||
impending_requests: Vec<Prd>,
|
||||
) -> Self {
|
||||
Self {
|
||||
states,
|
||||
shared_secrets: shared_secrets
|
||||
.into_iter()
|
||||
.map(|(k, v)| (k.to_string(), v))
|
||||
.collect(),
|
||||
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) {
|
||||
self.states.push(state);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user