refactor: thread loading improvements
This commit is contained in:
46
packages/system-wasm/Cargo.lock
generated
46
packages/system-wasm/Cargo.lock
generated
@ -23,18 +23,6 @@ version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b84bf0a05bbb2a83e5eb6fa36bb6e87baa08193c35ff52bbf6b38d8af2890e46"
|
||||
|
||||
[[package]]
|
||||
name = "argon2"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "17ba4cac0a46bc1d2912652a751c47f2a9f3a7fe89bcae2275d418f5270402f9"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"blake2",
|
||||
"cpufeatures",
|
||||
"password-hash",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "async-trait"
|
||||
version = "0.1.73"
|
||||
@ -52,27 +40,12 @@ version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
|
||||
|
||||
[[package]]
|
||||
name = "base64ct"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635"
|
||||
|
||||
[[package]]
|
||||
name = "blake2"
|
||||
version = "0.10.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46502ad458c9a52b69d4d4d32775c788b7a1b85e8bc9d482d92250fc0e3f8efe"
|
||||
dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
@ -283,7 +256,6 @@ checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"crypto-common",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -460,17 +432,6 @@ version = "11.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
|
||||
|
||||
[[package]]
|
||||
name = "password-hash"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "346f04948ba92c43e8469c1ee6736c7563d71012b17d40745260fe106aac2166"
|
||||
dependencies = [
|
||||
"base64ct",
|
||||
"rand_core",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "plotters"
|
||||
version = "0.3.5"
|
||||
@ -727,12 +688,6 @@ dependencies = [
|
||||
"sha2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.31"
|
||||
@ -748,7 +703,6 @@ dependencies = [
|
||||
name = "system-wasm"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"argon2",
|
||||
"console_error_panic_hook",
|
||||
"criterion",
|
||||
"hex",
|
||||
|
@ -8,7 +8,6 @@ edition = "2021"
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[dependencies]
|
||||
argon2 = "0.5.2"
|
||||
console_error_panic_hook = "0.1.7"
|
||||
hex = { version = "0.4.3", features = [], default-features = false }
|
||||
itertools = "0.11.0"
|
||||
|
@ -1 +1,11 @@
|
||||
# system-wasm
|
||||
|
||||
## Building
|
||||
|
||||
### Ubuntu/Debian
|
||||
|
||||
```bash
|
||||
sudo apt install clang
|
||||
cargo install wasm-pack
|
||||
yarn build
|
||||
```
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@snort/system-wasm",
|
||||
"version": "1.0.2",
|
||||
"version": "1.0.3",
|
||||
"packageManager": "yarn@3.6.3",
|
||||
"author": "Kieran",
|
||||
"license": "MIT",
|
||||
|
@ -1 +1,11 @@
|
||||
# system-wasm
|
||||
|
||||
## Building
|
||||
|
||||
### Ubuntu/Debian
|
||||
|
||||
```bash
|
||||
sudo apt install clang
|
||||
cargo install wasm-pack
|
||||
yarn build
|
||||
```
|
||||
|
7
packages/system-wasm/pkg/system_wasm.d.ts
vendored
7
packages/system-wasm/pkg/system_wasm.d.ts
vendored
@ -33,12 +33,6 @@ export function compress(val: any): any;
|
||||
* @returns {any}
|
||||
*/
|
||||
export function pow(val: any, target: any): any;
|
||||
/**
|
||||
* @param {any} password
|
||||
* @param {any} salt
|
||||
* @returns {any}
|
||||
*/
|
||||
export function argon2(password: any, salt: any): any;
|
||||
/**
|
||||
* @param {any} hash
|
||||
* @param {any} sig
|
||||
@ -62,7 +56,6 @@ export interface InitOutput {
|
||||
readonly flat_merge: (a: number, b: number) => void;
|
||||
readonly compress: (a: number, b: number) => void;
|
||||
readonly pow: (a: number, b: number, c: number) => void;
|
||||
readonly argon2: (a: number, b: number, c: number) => void;
|
||||
readonly schnorr_verify: (a: number, b: number, c: number, d: number) => void;
|
||||
readonly schnorr_verify_event: (a: number, b: number) => void;
|
||||
readonly rustsecp256k1_v0_9_1_context_create: (a: number) => number;
|
||||
|
@ -340,27 +340,6 @@ export function pow(val, target) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} password
|
||||
* @param {any} salt
|
||||
* @returns {any}
|
||||
*/
|
||||
export function argon2(password, salt) {
|
||||
try {
|
||||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
||||
wasm.argon2(retptr, addHeapObject(password), addHeapObject(salt));
|
||||
var r0 = getInt32Memory0()[retptr / 4 + 0];
|
||||
var r1 = getInt32Memory0()[retptr / 4 + 1];
|
||||
var r2 = getInt32Memory0()[retptr / 4 + 2];
|
||||
if (r2) {
|
||||
throw takeObject(r1);
|
||||
}
|
||||
return takeObject(r0);
|
||||
} finally {
|
||||
wasm.__wbindgen_add_to_stack_pointer(16);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {any} hash
|
||||
* @param {any} sig
|
||||
@ -484,10 +463,6 @@ function __wbg_get_imports() {
|
||||
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_object_clone_ref = function (arg0) {
|
||||
const ret = getObject(arg0);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_jsval_loose_eq = function (arg0, arg1) {
|
||||
const ret = getObject(arg0) == getObject(arg1);
|
||||
return ret;
|
||||
@ -507,6 +482,10 @@ function __wbg_get_imports() {
|
||||
const ret = arg0;
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_object_clone_ref = function (arg0) {
|
||||
const ret = getObject(arg0);
|
||||
return addHeapObject(ret);
|
||||
};
|
||||
imports.wbg.__wbindgen_string_new = function (arg0, arg1) {
|
||||
const ret = getStringFromWasm0(arg0, arg1);
|
||||
return addHeapObject(ret);
|
||||
|
Binary file not shown.
@ -7,7 +7,6 @@ export function get_diff(a: number, b: number, c: number): void;
|
||||
export function flat_merge(a: number, b: number): void;
|
||||
export function compress(a: number, b: number): void;
|
||||
export function pow(a: number, b: number, c: number): void;
|
||||
export function argon2(a: number, b: number, c: number): void;
|
||||
export function schnorr_verify(a: number, b: number, c: number, d: number): void;
|
||||
export function schnorr_verify_event(a: number, b: number): void;
|
||||
export function rustsecp256k1_v0_9_1_context_create(a: number): number;
|
||||
|
@ -21,35 +21,11 @@ mod tests {
|
||||
fn simple_diff_same() {
|
||||
let prev = vec![FlatReqFilter {
|
||||
id: Some("a".to_owned()),
|
||||
author: None,
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
}];
|
||||
let next = vec![FlatReqFilter {
|
||||
id: Some("a".to_owned()),
|
||||
author: None,
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
}];
|
||||
|
||||
let result = diff_filter(&prev, &next);
|
||||
@ -60,52 +36,16 @@ mod tests {
|
||||
fn simple_diff_add() {
|
||||
let prev = vec![FlatReqFilter {
|
||||
id: Some("a".to_owned()),
|
||||
author: None,
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
}];
|
||||
let next = vec![
|
||||
FlatReqFilter {
|
||||
id: Some("a".to_owned()),
|
||||
author: None,
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
id: Some("b".to_owned()),
|
||||
author: None,
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
|
||||
@ -114,19 +54,7 @@ mod tests {
|
||||
result,
|
||||
vec![FlatReqFilter {
|
||||
id: Some("b".to_owned()),
|
||||
author: None,
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
}]
|
||||
)
|
||||
}
|
||||
@ -135,35 +63,11 @@ mod tests {
|
||||
fn simple_diff_replace() {
|
||||
let prev = vec![FlatReqFilter {
|
||||
id: Some("a".to_owned()),
|
||||
author: None,
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
}];
|
||||
let next = vec![FlatReqFilter {
|
||||
id: Some("b".to_owned()),
|
||||
author: None,
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
}];
|
||||
|
||||
let result = diff_filter(&prev, &next);
|
||||
@ -171,19 +75,7 @@ mod tests {
|
||||
result,
|
||||
vec![FlatReqFilter {
|
||||
id: Some("b".to_owned()),
|
||||
author: None,
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
}]
|
||||
)
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
#[cfg(test)]
|
||||
use std::fmt::Debug;
|
||||
use std::hash::Hash;
|
||||
|
||||
use itertools::Itertools;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone)]
|
||||
enum StringOrNumberEntry<'a> {
|
||||
@ -11,7 +12,7 @@ enum StringOrNumberEntry<'a> {
|
||||
Number((&'static str, &'a i32)),
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct ReqFilter {
|
||||
#[serde(rename = "ids", skip_serializing_if = "Option::is_none")]
|
||||
pub ids: Option<HashSet<String>>,
|
||||
@ -33,6 +34,8 @@ pub struct ReqFilter {
|
||||
pub a_tag: Option<HashSet<String>>,
|
||||
#[serde(rename = "#g", skip_serializing_if = "Option::is_none")]
|
||||
pub g_tag: Option<HashSet<String>>,
|
||||
#[serde(rename = "relays", skip_serializing_if = "Option::is_none")]
|
||||
pub relays: Option<HashSet<String>>,
|
||||
#[serde(rename = "search", skip_serializing_if = "Option::is_none")]
|
||||
pub search: Option<String>,
|
||||
#[serde(rename = "since", skip_serializing_if = "Option::is_none")]
|
||||
@ -50,7 +53,7 @@ impl Debug for ReqFilter {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(PartialEq, PartialOrd, Clone, Serialize, Deserialize)]
|
||||
#[derive(PartialEq, PartialOrd, Clone, Serialize, Deserialize, Default)]
|
||||
pub struct FlatReqFilter {
|
||||
#[serde(rename = "ids", skip_serializing_if = "Option::is_none")]
|
||||
pub id: Option<String>,
|
||||
@ -74,6 +77,8 @@ pub struct FlatReqFilter {
|
||||
pub g_tag: Option<String>,
|
||||
#[serde(rename = "search", skip_serializing_if = "Option::is_none")]
|
||||
pub search: Option<String>,
|
||||
#[serde(rename = "relay", skip_serializing_if = "Option::is_none")]
|
||||
pub relay: Option<String>,
|
||||
#[serde(rename = "since", skip_serializing_if = "Option::is_none")]
|
||||
pub since: Option<i32>,
|
||||
#[serde(rename = "until", skip_serializing_if = "Option::is_none")]
|
||||
@ -117,11 +122,13 @@ impl Distance for FlatReqFilter {
|
||||
ret += prop_dist(&self.id, &b.id);
|
||||
ret += prop_dist(&self.kind, &b.kind);
|
||||
ret += prop_dist(&self.author, &b.author);
|
||||
ret += prop_dist(&self.relay, &b.relay);
|
||||
ret += prop_dist(&self.e_tag, &b.e_tag);
|
||||
ret += prop_dist(&self.p_tag, &b.p_tag);
|
||||
ret += prop_dist(&self.d_tag, &b.d_tag);
|
||||
ret += prop_dist(&self.r_tag, &b.r_tag);
|
||||
ret += prop_dist(&self.t_tag, &b.t_tag);
|
||||
ret += prop_dist(&self.g_tag, &b.g_tag);
|
||||
|
||||
ret
|
||||
}
|
||||
@ -143,26 +150,12 @@ impl CanMerge for FlatReqFilter {
|
||||
|
||||
impl From<Vec<&FlatReqFilter>> for ReqFilter {
|
||||
fn from(value: Vec<&FlatReqFilter>) -> Self {
|
||||
let ret = ReqFilter {
|
||||
ids: None,
|
||||
authors: None,
|
||||
kinds: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
};
|
||||
let ret = Default::default();
|
||||
value.iter().fold(ret, |mut acc, x| {
|
||||
array_prop_append(&x.id, &mut acc.ids);
|
||||
array_prop_append(&x.author, &mut acc.authors);
|
||||
array_prop_append(&x.kind, &mut acc.kinds);
|
||||
array_prop_append(&x.relay, &mut acc.relays);
|
||||
array_prop_append(&x.e_tag, &mut acc.e_tag);
|
||||
array_prop_append(&x.p_tag, &mut acc.p_tag);
|
||||
array_prop_append(&x.t_tag, &mut acc.t_tag);
|
||||
@ -182,26 +175,12 @@ impl From<Vec<&FlatReqFilter>> for ReqFilter {
|
||||
|
||||
impl From<Vec<&ReqFilter>> for ReqFilter {
|
||||
fn from(value: Vec<&ReqFilter>) -> Self {
|
||||
let ret = ReqFilter {
|
||||
ids: None,
|
||||
authors: None,
|
||||
kinds: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
};
|
||||
let ret = Default::default();
|
||||
value.iter().fold(ret, |mut acc, x| {
|
||||
array_prop_append_vec(&x.ids, &mut acc.ids);
|
||||
array_prop_append_vec(&x.authors, &mut acc.authors);
|
||||
array_prop_append_vec(&x.kinds, &mut acc.kinds);
|
||||
array_prop_append_vec(&x.relays, &mut acc.relays);
|
||||
array_prop_append_vec(&x.e_tag, &mut acc.e_tag);
|
||||
array_prop_append_vec(&x.p_tag, &mut acc.p_tag);
|
||||
array_prop_append_vec(&x.t_tag, &mut acc.t_tag);
|
||||
@ -245,6 +224,13 @@ impl Into<Vec<FlatReqFilter>> for &ReqFilter {
|
||||
.collect();
|
||||
inputs.push(t_ids);
|
||||
}
|
||||
if let Some(relays) = &self.relays {
|
||||
let t_relays = relays
|
||||
.iter()
|
||||
.map(|z| StringOrNumberEntry::String(("relay", z)))
|
||||
.collect();
|
||||
inputs.push(t_relays);
|
||||
}
|
||||
if let Some(e_tags) = &self.e_tag {
|
||||
let t_ids = e_tags
|
||||
.iter()
|
||||
@ -313,6 +299,14 @@ impl Into<Vec<FlatReqFilter>> for &ReqFilter {
|
||||
}
|
||||
None
|
||||
}),
|
||||
relay: p.iter().find_map(|q| {
|
||||
if let StringOrNumberEntry::String((k, v)) = q {
|
||||
if (*k).eq("relay") {
|
||||
return Some((*v).to_string());
|
||||
}
|
||||
}
|
||||
None
|
||||
}),
|
||||
kind: p.iter().find_map(|q| {
|
||||
if let StringOrNumberEntry::Number((k, v)) = q {
|
||||
if (*k).eq("kind") {
|
||||
@ -394,6 +388,7 @@ impl Distance for ReqFilter {
|
||||
ret += prop_dist_vec(&self.ids, &b.ids);
|
||||
ret += prop_dist_vec(&self.kinds, &b.kinds);
|
||||
ret += prop_dist_vec(&self.authors, &b.authors);
|
||||
ret += prop_dist_vec(&self.relays, &b.relays);
|
||||
ret += prop_dist_vec(&self.e_tag, &b.e_tag);
|
||||
ret += prop_dist_vec(&self.p_tag, &b.p_tag);
|
||||
ret += prop_dist_vec(&self.d_tag, &b.d_tag);
|
||||
@ -478,9 +473,10 @@ fn array_prop_append_vec<T: Clone + Eq + Hash>(
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::ReqFilter;
|
||||
use std::collections::HashSet;
|
||||
|
||||
use crate::filter::FlatReqFilter;
|
||||
use crate::ReqFilter;
|
||||
|
||||
#[test]
|
||||
fn test_expand_filter() {
|
||||
@ -493,16 +489,9 @@ mod tests {
|
||||
kinds: Some(HashSet::from([1, 2, 3])),
|
||||
ids: Some(HashSet::from(["x".to_owned(), "y".to_owned()])),
|
||||
p_tag: Some(HashSet::from(["a".to_owned()])),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let output: Vec<FlatReqFilter> = (&input).into();
|
||||
@ -512,288 +501,162 @@ mod tests {
|
||||
kind: Some(1),
|
||||
id: Some("x".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("a".to_owned()),
|
||||
kind: Some(1),
|
||||
id: Some("y".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("a".to_owned()),
|
||||
kind: Some(2),
|
||||
id: Some("x".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("a".to_owned()),
|
||||
kind: Some(2),
|
||||
id: Some("y".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("a".to_owned()),
|
||||
kind: Some(3),
|
||||
id: Some("x".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("a".to_owned()),
|
||||
kind: Some(3),
|
||||
id: Some("y".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("b".to_owned()),
|
||||
kind: Some(1),
|
||||
id: Some("x".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("b".to_owned()),
|
||||
kind: Some(1),
|
||||
id: Some("y".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("b".to_owned()),
|
||||
kind: Some(2),
|
||||
id: Some("x".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("b".to_owned()),
|
||||
kind: Some(2),
|
||||
id: Some("y".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("b".to_owned()),
|
||||
kind: Some(3),
|
||||
id: Some("x".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("b".to_owned()),
|
||||
kind: Some(3),
|
||||
id: Some("y".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("c".to_owned()),
|
||||
kind: Some(1),
|
||||
id: Some("x".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("c".to_owned()),
|
||||
kind: Some(1),
|
||||
id: Some("y".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("c".to_owned()),
|
||||
kind: Some(2),
|
||||
id: Some("x".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("c".to_owned()),
|
||||
kind: Some(2),
|
||||
id: Some("y".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("c".to_owned()),
|
||||
kind: Some(3),
|
||||
id: Some("x".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
author: Some("c".to_owned()),
|
||||
kind: Some(3),
|
||||
id: Some("y".to_owned()),
|
||||
p_tag: Some("a".to_owned()),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: Some(99),
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
e_tag: None,
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
assert_eq!(output.len(), expected.len());
|
||||
|
@ -1,6 +1,5 @@
|
||||
extern crate console_error_panic_hook;
|
||||
|
||||
use argon2::{Argon2};
|
||||
use secp256k1::{Message, XOnlyPublicKey, SECP256K1};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
@ -90,16 +89,6 @@ pub fn pow(val: JsValue, target: JsValue) -> Result<JsValue, JsValue> {
|
||||
Ok(serde_wasm_bindgen::to_value(&val_parsed)?)
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn argon2(password: JsValue, salt: JsValue) -> Result<JsValue, JsValue> {
|
||||
console_error_panic_hook::set_once();
|
||||
let password_parsed: String = serde_wasm_bindgen::from_value(password)?;
|
||||
let salt_parsed: String = serde_wasm_bindgen::from_value(salt)?;
|
||||
let mut key = [0u8; 32];
|
||||
Argon2::default().hash_password_into(password_parsed.as_bytes(), salt_parsed.as_bytes(), &mut key).expect("Failed to generate key");
|
||||
Ok(serde_wasm_bindgen::to_value(&hex::encode(key))?)
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn schnorr_verify(hash: JsValue, sig: JsValue, pub_key: JsValue) -> Result<bool, JsValue> {
|
||||
console_error_panic_hook::set_once();
|
||||
@ -137,15 +126,7 @@ mod tests {
|
||||
fn flat_merge_expanded() {
|
||||
let input = vec![
|
||||
ReqFilter {
|
||||
ids: None,
|
||||
kinds: Some(HashSet::from([1, 6969, 6])),
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
authors: Some(HashSet::from([
|
||||
"kieran".to_string(),
|
||||
"snort".to_string(),
|
||||
@ -155,56 +136,23 @@ mod tests {
|
||||
])),
|
||||
since: Some(1),
|
||||
until: Some(100),
|
||||
search: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
ReqFilter {
|
||||
ids: None,
|
||||
kinds: Some(HashSet::from([4])),
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
authors: Some(HashSet::from(["kieran".to_string()])),
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
ReqFilter {
|
||||
ids: None,
|
||||
authors: None,
|
||||
kinds: Some(HashSet::from([4])),
|
||||
e_tag: None,
|
||||
p_tag: Some(HashSet::from(["kieran".to_string()])),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
ReqFilter {
|
||||
ids: None,
|
||||
kinds: Some(HashSet::from([1000])),
|
||||
authors: Some(HashSet::from(["snort".to_string()])),
|
||||
p_tag: Some(HashSet::from(["kieran".to_string()])),
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
e_tag: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
|
||||
|
@ -59,83 +59,25 @@ mod tests {
|
||||
fn distance() {
|
||||
let a = FlatReqFilter {
|
||||
id: Some("a".to_owned()),
|
||||
author: None,
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
};
|
||||
let b = FlatReqFilter {
|
||||
id: Some("a".to_owned()),
|
||||
author: None,
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
};
|
||||
let c = FlatReqFilter {
|
||||
id: Some("c".to_owned()),
|
||||
author: None,
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
};
|
||||
let d = FlatReqFilter {
|
||||
id: Some("a".to_owned()),
|
||||
author: None,
|
||||
kind: Some(1),
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
};
|
||||
let e = FlatReqFilter {
|
||||
id: Some("e".to_owned()),
|
||||
author: None,
|
||||
kind: Some(1),
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(a.distance(&b), 0);
|
||||
assert_eq!(a.distance(&c), 1);
|
||||
@ -148,51 +90,21 @@ mod tests {
|
||||
let a = FlatReqFilter {
|
||||
id: Some("0".to_owned()),
|
||||
author: Some("a".to_owned()),
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
..Default::default()
|
||||
};
|
||||
let b = FlatReqFilter {
|
||||
id: Some("0".to_owned()),
|
||||
author: Some("b".to_owned()),
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let output = ReqFilter {
|
||||
ids: Some(HashSet::from(["0".to_owned()])),
|
||||
authors: Some(HashSet::from(["a".to_owned(), "b".to_owned()])),
|
||||
kinds: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
..Default::default()
|
||||
};
|
||||
assert_eq!(ReqFilter::from(vec![&a, &b]), output);
|
||||
}
|
||||
@ -202,50 +114,20 @@ mod tests {
|
||||
let a = FlatReqFilter {
|
||||
id: Some("0".to_owned()),
|
||||
author: Some("a".to_owned()),
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
..Default::default()
|
||||
};
|
||||
let b = FlatReqFilter {
|
||||
id: Some("0".to_owned()),
|
||||
author: Some("b".to_owned()),
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: Some(10),
|
||||
..Default::default()
|
||||
};
|
||||
let c = FlatReqFilter {
|
||||
id: Some("0".to_owned()),
|
||||
author: Some("b".to_owned()),
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: Some(100),
|
||||
..Default::default()
|
||||
};
|
||||
assert!(&a.can_merge(&b));
|
||||
assert!(!&b.can_merge(&c));
|
||||
@ -257,146 +139,44 @@ mod tests {
|
||||
FlatReqFilter {
|
||||
id: Some("0".to_owned()),
|
||||
author: Some("a".to_owned()),
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
id: Some("0".to_owned()),
|
||||
author: Some("b".to_owned()),
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
id: None,
|
||||
author: None,
|
||||
kind: Some(1),
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
id: None,
|
||||
author: None,
|
||||
kind: Some(2),
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
id: None,
|
||||
author: None,
|
||||
kind: Some(2),
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
id: Some("0".to_owned()),
|
||||
author: Some("c".to_owned()),
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
id: None,
|
||||
author: Some("c".to_owned()),
|
||||
kind: Some(1),
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
id: None,
|
||||
author: Some("c".to_owned()),
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: Some(100),
|
||||
..Default::default()
|
||||
},
|
||||
FlatReqFilter {
|
||||
id: Some("1".to_owned()),
|
||||
author: Some("c".to_owned()),
|
||||
kind: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
let output = vec![
|
||||
@ -407,82 +187,26 @@ mod tests {
|
||||
"b".to_owned(),
|
||||
"c".to_owned(),
|
||||
])),
|
||||
kinds: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
ReqFilter {
|
||||
ids: None,
|
||||
authors: None,
|
||||
kinds: Some(HashSet::from([1, 2])),
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
ReqFilter {
|
||||
ids: None,
|
||||
authors: Some(HashSet::from(["c".to_owned()])),
|
||||
kinds: Some(HashSet::from([1])),
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
ReqFilter {
|
||||
ids: None,
|
||||
authors: Some(HashSet::from(["c".to_owned()])),
|
||||
kinds: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: Some(100),
|
||||
..Default::default()
|
||||
},
|
||||
ReqFilter {
|
||||
ids: Some(HashSet::from(["1".to_owned()])),
|
||||
authors: Some(HashSet::from(["c".to_owned()])),
|
||||
kinds: None,
|
||||
e_tag: None,
|
||||
p_tag: None,
|
||||
t_tag: None,
|
||||
d_tag: None,
|
||||
r_tag: None,
|
||||
a_tag: None,
|
||||
g_tag: None,
|
||||
search: None,
|
||||
since: None,
|
||||
until: None,
|
||||
limit: None,
|
||||
..Default::default()
|
||||
},
|
||||
];
|
||||
|
||||
|
Reference in New Issue
Block a user