mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2025-03-14 18:55:37 +00:00
pass stream width to ruma state res
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
3b95af9a18
commit
5a335933b8
4 changed files with 48 additions and 53 deletions
26
Cargo.lock
generated
26
Cargo.lock
generated
|
@ -3175,7 +3175,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma"
|
||||
version = "0.10.1"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=112ccc24cb14de26757715d611285d0806d5d91f#112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=d3ed3194ebe96b921d06d1d3e607f0bf7873f792#d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
dependencies = [
|
||||
"assign",
|
||||
"js_int",
|
||||
|
@ -3197,7 +3197,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-appservice-api"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=112ccc24cb14de26757715d611285d0806d5d91f#112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=d3ed3194ebe96b921d06d1d3e607f0bf7873f792#d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"ruma-common",
|
||||
|
@ -3209,7 +3209,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-client-api"
|
||||
version = "0.18.0"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=112ccc24cb14de26757715d611285d0806d5d91f#112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=d3ed3194ebe96b921d06d1d3e607f0bf7873f792#d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
dependencies = [
|
||||
"as_variant",
|
||||
"assign",
|
||||
|
@ -3232,7 +3232,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-common"
|
||||
version = "0.13.0"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=112ccc24cb14de26757715d611285d0806d5d91f#112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=d3ed3194ebe96b921d06d1d3e607f0bf7873f792#d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
dependencies = [
|
||||
"as_variant",
|
||||
"base64 0.22.1",
|
||||
|
@ -3262,7 +3262,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-events"
|
||||
version = "0.28.1"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=112ccc24cb14de26757715d611285d0806d5d91f#112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=d3ed3194ebe96b921d06d1d3e607f0bf7873f792#d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
dependencies = [
|
||||
"as_variant",
|
||||
"indexmap 2.7.0",
|
||||
|
@ -3286,7 +3286,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-federation-api"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=112ccc24cb14de26757715d611285d0806d5d91f#112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=d3ed3194ebe96b921d06d1d3e607f0bf7873f792#d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http",
|
||||
|
@ -3304,7 +3304,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-identifiers-validation"
|
||||
version = "0.9.5"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=112ccc24cb14de26757715d611285d0806d5d91f#112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=d3ed3194ebe96b921d06d1d3e607f0bf7873f792#d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"thiserror 2.0.7",
|
||||
|
@ -3313,7 +3313,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-identity-service-api"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=112ccc24cb14de26757715d611285d0806d5d91f#112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=d3ed3194ebe96b921d06d1d3e607f0bf7873f792#d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"ruma-common",
|
||||
|
@ -3323,7 +3323,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-macros"
|
||||
version = "0.13.0"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=112ccc24cb14de26757715d611285d0806d5d91f#112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=d3ed3194ebe96b921d06d1d3e607f0bf7873f792#d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"proc-macro-crate",
|
||||
|
@ -3338,7 +3338,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-push-gateway-api"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=112ccc24cb14de26757715d611285d0806d5d91f#112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=d3ed3194ebe96b921d06d1d3e607f0bf7873f792#d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"ruma-common",
|
||||
|
@ -3350,7 +3350,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-server-util"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=112ccc24cb14de26757715d611285d0806d5d91f#112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=d3ed3194ebe96b921d06d1d3e607f0bf7873f792#d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
dependencies = [
|
||||
"headers",
|
||||
"http",
|
||||
|
@ -3363,7 +3363,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-signatures"
|
||||
version = "0.15.0"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=112ccc24cb14de26757715d611285d0806d5d91f#112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=d3ed3194ebe96b921d06d1d3e607f0bf7873f792#d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
dependencies = [
|
||||
"base64 0.22.1",
|
||||
"ed25519-dalek",
|
||||
|
@ -3379,7 +3379,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ruma-state-res"
|
||||
version = "0.11.0"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=112ccc24cb14de26757715d611285d0806d5d91f#112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
source = "git+https://github.com/girlbossceo/ruwuma?rev=d3ed3194ebe96b921d06d1d3e607f0bf7873f792#d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"js_int",
|
||||
|
|
|
@ -335,7 +335,7 @@ version = "0.1.2"
|
|||
[workspace.dependencies.ruma]
|
||||
git = "https://github.com/girlbossceo/ruwuma"
|
||||
#branch = "conduwuit-changes"
|
||||
rev = "112ccc24cb14de26757715d611285d0806d5d91f"
|
||||
rev = "d3ed3194ebe96b921d06d1d3e607f0bf7873f792"
|
||||
features = [
|
||||
"compat",
|
||||
"rand",
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::{
|
|||
|
||||
use conduwuit::{
|
||||
debug, err, implement,
|
||||
utils::stream::{IterStream, WidebandExt},
|
||||
utils::stream::{automatic_width, IterStream, WidebandExt},
|
||||
Result,
|
||||
};
|
||||
use futures::{FutureExt, StreamExt, TryFutureExt};
|
||||
|
@ -75,22 +75,10 @@ pub async fn resolve_state(
|
|||
.await;
|
||||
|
||||
debug!("Resolving state");
|
||||
let lock = self.services.globals.stateres_mutex.lock();
|
||||
|
||||
let event_fetch = |event_id| self.event_fetch(event_id);
|
||||
let event_exists = |event_id| self.event_exists(event_id);
|
||||
let state = state_res::resolve(
|
||||
room_version_id,
|
||||
&fork_states,
|
||||
&auth_chain_sets,
|
||||
&event_fetch,
|
||||
&event_exists,
|
||||
)
|
||||
.boxed()
|
||||
.await
|
||||
.map_err(|e| err!(Database(error!("State resolution failed: {e:?}"))))?;
|
||||
|
||||
drop(lock);
|
||||
let state = self
|
||||
.state_resolution(room_version_id, &fork_states, &auth_chain_sets)
|
||||
.boxed()
|
||||
.await?;
|
||||
|
||||
debug!("State resolution done.");
|
||||
let state_events: Vec<_> = state
|
||||
|
@ -119,3 +107,26 @@ pub async fn resolve_state(
|
|||
|
||||
Ok(Arc::new(new_room_state))
|
||||
}
|
||||
|
||||
#[implement(super::Service)]
|
||||
#[tracing::instrument(name = "ruma", level = "debug", skip_all)]
|
||||
pub async fn state_resolution(
|
||||
&self,
|
||||
room_version: &RoomVersionId,
|
||||
state_sets: &[StateMap<Arc<EventId>>],
|
||||
auth_chain_sets: &Vec<HashSet<Arc<EventId>>>,
|
||||
) -> Result<StateMap<Arc<EventId>>> {
|
||||
//TODO: ???
|
||||
let _lock = self.services.globals.stateres_mutex.lock();
|
||||
|
||||
state_res::resolve(
|
||||
room_version,
|
||||
state_sets.iter(),
|
||||
auth_chain_sets,
|
||||
&|event_id| self.event_fetch(event_id),
|
||||
&|event_id| self.event_exists(event_id),
|
||||
automatic_width(),
|
||||
)
|
||||
.await
|
||||
.map_err(|e| err!(error!("State resolution failed: {e:?}")))
|
||||
}
|
||||
|
|
|
@ -11,10 +11,7 @@ use conduwuit::{
|
|||
PduEvent, Result,
|
||||
};
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use ruma::{
|
||||
state_res::{self, StateMap},
|
||||
EventId, RoomId, RoomVersionId,
|
||||
};
|
||||
use ruma::{state_res::StateMap, EventId, RoomId, RoomVersionId};
|
||||
|
||||
// TODO: if we know the prev_events of the incoming event we can avoid the
|
||||
#[implement(super::Service)]
|
||||
|
@ -157,24 +154,11 @@ pub(super) async fn state_at_incoming_resolved(
|
|||
fork_states.push(state);
|
||||
}
|
||||
|
||||
let lock = self.services.globals.stateres_mutex.lock();
|
||||
|
||||
let event_fetch = |event_id| self.event_fetch(event_id);
|
||||
let event_exists = |event_id| self.event_exists(event_id);
|
||||
let result = state_res::resolve(
|
||||
room_version_id,
|
||||
&fork_states,
|
||||
&auth_chain_sets,
|
||||
&event_fetch,
|
||||
&event_exists,
|
||||
)
|
||||
.boxed()
|
||||
.await
|
||||
.map_err(|e| err!(Database(warn!(?e, "State resolution on prev events failed."))));
|
||||
|
||||
drop(lock);
|
||||
|
||||
let Ok(new_state) = result else {
|
||||
let Ok(new_state) = self
|
||||
.state_resolution(room_version_id, &fork_states, &auth_chain_sets)
|
||||
.boxed()
|
||||
.await
|
||||
else {
|
||||
return Ok(None);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue