|
@@ -132,7 +132,7 @@ impl Storage for Memory {
|
|
return Ok(None);
|
|
return Ok(None);
|
|
}
|
|
}
|
|
|
|
|
|
- async fn get_by_filter(&self, query: Filter) -> Result<Self::Cursor<'_>, Error> {
|
|
|
|
|
|
+ async fn get_by_filter(&self, mut query: Filter) -> Result<Self::Cursor<'_>, Error> {
|
|
let limit = if query.limit == 0 {
|
|
let limit = if query.limit == 0 {
|
|
None
|
|
None
|
|
} else {
|
|
} else {
|
|
@@ -142,28 +142,25 @@ impl Storage for Memory {
|
|
let (index, index_prefixes) = if !query.references_to_event.is_empty() {
|
|
let (index, index_prefixes) = if !query.references_to_event.is_empty() {
|
|
(
|
|
(
|
|
self.indexes.ref_event.read().await,
|
|
self.indexes.ref_event.read().await,
|
|
- query
|
|
|
|
- .references_to_event
|
|
|
|
- .iter()
|
|
|
|
- .map(|c| c.as_ref().to_vec())
|
|
|
|
|
|
+ std::mem::take(&mut query.references_to_event)
|
|
|
|
+ .into_iter()
|
|
|
|
+ .map(|c| c.take())
|
|
.collect::<VecDeque<_>>(),
|
|
.collect::<VecDeque<_>>(),
|
|
)
|
|
)
|
|
} else if !query.references_to_public_key.is_empty() {
|
|
} else if !query.references_to_public_key.is_empty() {
|
|
(
|
|
(
|
|
self.indexes.ref_pub_key.read().await,
|
|
self.indexes.ref_pub_key.read().await,
|
|
- query
|
|
|
|
- .references_to_public_key
|
|
|
|
- .iter()
|
|
|
|
- .map(|c| c.as_ref().to_vec())
|
|
|
|
|
|
+ std::mem::take(&mut query.references_to_public_key)
|
|
|
|
+ .into_iter()
|
|
|
|
+ .map(|c| c.take())
|
|
.collect::<VecDeque<_>>(),
|
|
.collect::<VecDeque<_>>(),
|
|
)
|
|
)
|
|
} else if !query.ids.is_empty() {
|
|
} else if !query.ids.is_empty() {
|
|
(
|
|
(
|
|
self.indexes.ids_by_time.read().await,
|
|
self.indexes.ids_by_time.read().await,
|
|
- query
|
|
|
|
- .ids
|
|
|
|
- .iter()
|
|
|
|
- .map(|c| c.as_ref().to_vec())
|
|
|
|
|
|
+ std::mem::take(&mut query.ids)
|
|
|
|
+ .into_iter()
|
|
|
|
+ .map(|c| c.take())
|
|
.collect::<VecDeque<_>>(),
|
|
.collect::<VecDeque<_>>(),
|
|
)
|
|
)
|
|
} else {
|
|
} else {
|