Skip to content

Commit

Permalink
refactor: Take command: &str instead of by String in `Store::get_…
Browse files Browse the repository at this point in the history
…chain`
  • Loading branch information
matheus23 committed Mar 22, 2024
1 parent b1cede0 commit 0dd1ecb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/delegation/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ where

let proofs = &self
.store
.get_chain(&self.did, &subject, command.clone(), vec![], now)
.get_chain(&self.did, &subject, &command, vec![], now)
.map_err(DelegateError::StoreError)?
.ok_or(DelegateError::ProofsNotFound)?;
let to_delegate = proofs.first().1.payload();
Expand Down
7 changes: 4 additions & 3 deletions src/delegation/store/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use libipld_core::codec::Encode;
use libipld_core::ipld::Ipld;
use libipld_core::{cid::Cid, codec::Codec};
use nonempty::NonEmpty;
use std::borrow::Cow;
use std::{
collections::{BTreeMap, BTreeSet},
convert::Infallible,
Expand Down Expand Up @@ -191,7 +192,7 @@ where
&self,
aud: &DID,
subject: &Option<DID>,
command: String,
command: &str,
policy: Vec<Predicate>, // FIXME
now: SystemTime,
) -> Result<Option<NonEmpty<(Cid, Arc<Delegation<DID, V, Enc>>)>>, Self::DelegationStoreError>
Expand All @@ -209,9 +210,9 @@ where
let mut hypothesis_chain = vec![];

let corrected_target_command = if command.ends_with('/') {
command
Cow::Borrowed(command)
} else {
format!("{}/", command)
Cow::Owned(format!("{command}/"))
};

parent_candidate_stack.push(sub_candidates.iter().chain(powerline_candidates.iter()));
Expand Down
8 changes: 4 additions & 4 deletions src/delegation/store/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub trait Store<DID: Did, V: varsig::Header<Enc>, Enc: Codec + TryFrom<u64> + In
&self,
audience: &DID,
subject: &Option<DID>,
command: String,
command: &str,
policy: Vec<Predicate>,
now: SystemTime,
) -> Result<Option<NonEmpty<(Cid, Arc<Delegation<DID, V, Enc>>)>>, Self::DelegationStoreError>;
Expand All @@ -40,7 +40,7 @@ pub trait Store<DID: Did, V: varsig::Header<Enc>, Enc: Codec + TryFrom<u64> + In
&self,
audience: &DID,
subject: &Option<DID>,
command: String,
command: &str,
policy: Vec<Predicate>,
now: SystemTime,
) -> Result<Option<NonEmpty<Cid>>, Self::DelegationStoreError> {
Expand All @@ -52,7 +52,7 @@ pub trait Store<DID: Did, V: varsig::Header<Enc>, Enc: Codec + TryFrom<u64> + In
&self,
issuer: DID,
audience: &DID,
command: String,
command: &str,
policy: Vec<Predicate>,
now: SystemTime,
) -> Result<bool, Self::DelegationStoreError> {
Expand Down Expand Up @@ -98,7 +98,7 @@ impl<T: Store<DID, V, C>, DID: Did, V: varsig::Header<C>, C: Codec + TryFrom<u64
&self,
audience: &DID,
subject: &Option<DID>,
command: String,
command: &str,
policy: Vec<Predicate>,
now: SystemTime,
) -> Result<Option<NonEmpty<(Cid, Arc<Delegation<DID, V, C>>)>>, Self::DelegationStoreError>
Expand Down
2 changes: 1 addition & 1 deletion src/invocation/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ where
.get_chain_cids(
&self.did,
&Some(subject.clone()),
ability.to_command(),
&ability.to_command(),
vec![],
now,
)?
Expand Down

0 comments on commit 0dd1ecb

Please sign in to comment.