pub fn find_pools(
        &self,
        protocol: &str,
        token_a: &str,
        token_b: &str,
    ) -> Result<Vec<Pool>, FarmClientError> {
        self.reload_pool_refs_if_stale()?;
        let pattern1 = format!("{}.{}-{}-", protocol, token_a, token_b);
        let pattern2 = format!("{}.{}-{}-", protocol, token_b, token_a);
        let mut res = vec![];
        for (name, _) in self.pool_refs.borrow().data.iter() {
            if name.starts_with(&pattern1) || name.starts_with(&pattern2) {
                res.push(self.get_pool(name)?);
            }
        }
        if res.is_empty() {
            Err(FarmClientError::RecordNotFound(format!(
                "{} Pool with tokens {} and {}",
                protocol, token_a, token_b
            )))
        } else {
            res.sort_by(|a, b| b.version.cmp(&a.version));
            Ok(res)
        }
    }
/// Returns all Pools with tokens A and B sorted by version for the given protocol
Returns all Pools with tokens A and B sorted by version for the given protocol
Returns all Pools with tokens A and B sorted by version for the given protocol
pub fn find_pools(
        &self,
        protocol: &str,
        token_a: &str,
        token_b: &str,
    ) -> Result<Vec<Pool>, FarmClientError> {
        self.reload_pool_refs_if_stale()?;
        let pattern1 = format!("{}.{}-{}-", protocol, token_a, token_b);
        let pattern2 = format!("{}.{}-{}-", protocol, token_b, token_a);
        let mut res = vec![];
        for (name, _) in self.pool_refs.borrow().data.iter() {
            if name.starts_with(&pattern1) || name.starts_with(&pattern2) {
                res.push(self.get_pool(name)?);
            }
        }
        if res.is_empty() {
            Err(FarmClientError::RecordNotFound(format!(
                "{} Pool with tokens {} and {}",
                protocol, token_a, token_b
            )))
        } else {
            res.sort_by(|a, b| b.version.cmp(&a.version));
            Ok(res)
        }
    }
pub fn find_pools ( & self , protocol : & str , token_a : & str , token_b : & str , ) -> Result < Vec < Pool > , FarmClientError > { self . reload_pool_refs_if_stale ( ) ? ; let pattern1 = format ! ( " " protocol token_a token_b ) ; let pattern2 = format ! ( " " protocol token_b token_a ) ; let mut res = vec ! [ ] ; for ( name , _ ) in self . pool_refs . borrow ( ) . data . iter ( ) { if name . starts_with ( & pattern1 ) || name . starts_with ( & pattern2 ) { res . push ( self . get_pool ( name ) ? ) ; } } if res . is_empty ( ) { Err ( FarmClientError :: RecordNotFound ( format ! ( " " protocol token_a token_b ) ) ) } else { res . sort_by ( | a , b | b . version . cmp ( & a . version ) ) ; Ok ( res ) } }
Returns all Pools with tokens A and B sorted by version for the given protocol
Returns all Pools with tokens A and B sorted by version for the given protocol
&self
protocol
&str
token_a
&str
token_b
&str
&self
protocol
&str
token_a
&str
token_b
&str