diff --git a/lib/src/core.rs b/lib/src/core.rs index 35316e22..90fbe715 100644 --- a/lib/src/core.rs +++ b/lib/src/core.rs @@ -3,6 +3,7 @@ use ring::signature; use rusqlite::types::{FromSql, FromSqlError, ToSql, ValueRef}; use serde::{Deserialize, Serialize}; use std::collections::{BTreeMap, HashMap, HashSet}; +use std::hash::{Hash, Hasher}; use thiserror::Error; lazy_static::lazy_static! { @@ -470,7 +471,7 @@ pub enum Message { Response((Response, Option)), } -#[derive(Clone, Debug, Hash, Serialize, Deserialize)] +#[derive(Clone, Debug, Serialize, Deserialize)] pub struct Capability { pub issuer: Address, pub params: String, @@ -488,6 +489,15 @@ impl PartialEq for Capability { } } +impl Hash for Capability { + fn hash(&self, state: &mut H) { + self.issuer.hash(state); + let params: serde_json::Value = + serde_json::from_str(&self.params).unwrap_or_default(); + params.hash(state); + } +} + impl Capability { pub fn new(issuer: T, params: U) -> Self where