mirror of
https://github.com/uqbar-dao/nectar.git
synced 2024-11-23 03:44:04 +03:00
fix caps by hashing JSON-ified params (to avoid, eg, whitespace diffs)
This commit is contained in:
parent
6ae6fb24fc
commit
7413646fc4
@ -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<Context>)),
|
||||
}
|
||||
|
||||
#[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<H: Hasher>(&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<T, U>(issuer: T, params: U) -> Self
|
||||
where
|
||||
|
Loading…
Reference in New Issue
Block a user