Skip to content

Commit 141c782

Browse files
committed
1 parent 8ea2191 commit 141c782

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
* pool: bump `async-wsocket` to `v0.6` ([Yuki Kishimoto])
4040
* database: not match event if `Filter::search` field is set ([Yuki Kishimoto])
4141
* database: avoid to copy `EventId` in `Event::decode` ([Yuki Kishimoto])
42+
* database: use `Vec` instead of `BTreeSet` as inner value for `TagIndexValues` ([Yuki Kishimoto])
4243
* sdk: rename `Proxy` and `ProxyTarget` to `Connection` and `ConnectionTarget` ([Yuki Kishimoto])
4344
* sqlite: use `ValueRef` instead of owned one ([Yuki Kishimoto])
4445
* cli: improve `sync` command ([Yuki Kishimoto])
@@ -65,6 +66,7 @@
6566

6667
* pool: fix `Event` notification variant sent also for events sent by the SDK ([Yuki Kishimoto])
6768
* database: fix indexes `QueryPattern` ([Yuki Kishimoto])
69+
* database: fix query issue due to wrong tag value order ([Yuki Kishimoto])
6870

6971
### Removed
7072

crates/nostr-database/src/tag_indexes.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
//! Tag Indexes
66
7-
use std::collections::{BTreeMap, BTreeSet};
7+
use std::collections::BTreeMap;
88
use std::ops::{Deref, DerefMut};
99

1010
#[cfg(feature = "flatbuf")]
@@ -48,10 +48,7 @@ impl TagIndexes {
4848
if t.len() > 1 {
4949
if let Some(single_letter_tag) = single_char_tagname(t.get(0)) {
5050
let inner = hash(t.get(1));
51-
tag_index
52-
.entry(single_letter_tag)
53-
.or_default()
54-
.insert(inner);
51+
tag_index.entry(single_letter_tag).or_default().push(inner);
5552
}
5653
}
5754
}
@@ -60,9 +57,10 @@ impl TagIndexes {
6057
}
6158

6259
/// Get hashed `d` tag
60+
#[inline]
6361
pub fn identifier(&self) -> Option<[u8; TAG_INDEX_VALUE_SIZE]> {
6462
let values = self.inner.get(&SingleLetterTag::lowercase(Alphabet::D))?;
65-
values.iter().next().copied()
63+
values.first().copied()
6664
}
6765
}
6866

@@ -76,10 +74,7 @@ where
7674
iter.filter_map(|t| Some((t.single_letter_tag()?, t.content()?)))
7775
{
7876
let inner = hash(content);
79-
tag_index
80-
.entry(single_letter_tag)
81-
.or_default()
82-
.insert(inner);
77+
tag_index.entry(single_letter_tag).or_default().push(inner);
8378
}
8479
tag_index
8580
}
@@ -108,11 +103,11 @@ where
108103
/// Tag Index Values
109104
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
110105
pub struct TagIndexValues {
111-
inner: BTreeSet<[u8; TAG_INDEX_VALUE_SIZE]>,
106+
inner: Vec<[u8; TAG_INDEX_VALUE_SIZE]>,
112107
}
113108

114109
impl Deref for TagIndexValues {
115-
type Target = BTreeSet<[u8; TAG_INDEX_VALUE_SIZE]>;
110+
type Target = Vec<[u8; TAG_INDEX_VALUE_SIZE]>;
116111

117112
fn deref(&self) -> &Self::Target {
118113
&self.inner

0 commit comments

Comments
 (0)