mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-09-11 21:13:02 +02:00
Compare commits
5 commits
2106e4e9f4
...
60b8c9f5f2
Author | SHA1 | Date | |
---|---|---|---|
|
60b8c9f5f2 | ||
|
c83f1ddb71 | ||
|
a75eacd544 | ||
|
e15d71d230 | ||
|
a7929c1931 |
1 changed files with 25 additions and 5 deletions
|
@ -3,11 +3,7 @@ use std::{
|
||||||
time::Instant,
|
time::Instant,
|
||||||
};
|
};
|
||||||
|
|
||||||
use conduwuit::{
|
use conduwuit::{Event, PduEvent, debug, debug_error, implement, matrix::event::gen_event_id_canonical_json, trace, utils::continue_exponential_backoff_secs, warn, debug_warn};
|
||||||
Event, PduEvent, debug, debug_error, implement,
|
|
||||||
matrix::event::gen_event_id_canonical_json, trace, utils::continue_exponential_backoff_secs,
|
|
||||||
warn,
|
|
||||||
};
|
|
||||||
use ruma::{
|
use ruma::{
|
||||||
CanonicalJsonValue, EventId, OwnedEventId, RoomId, ServerName,
|
CanonicalJsonValue, EventId, OwnedEventId, RoomId, ServerName,
|
||||||
api::federation::event::get_event,
|
api::federation::event::get_event,
|
||||||
|
@ -70,6 +66,30 @@ where
|
||||||
|
|
||||||
let mut events_all = HashSet::with_capacity(todo_auth_events.len());
|
let mut events_all = HashSet::with_capacity(todo_auth_events.len());
|
||||||
while let Some(next_id) = todo_auth_events.pop_front() {
|
while let Some(next_id) = todo_auth_events.pop_front() {
|
||||||
|
if let Some((time, tries)) = self
|
||||||
|
.services
|
||||||
|
.globals
|
||||||
|
.bad_event_ratelimiter
|
||||||
|
.read()
|
||||||
|
.get(&*next_id)
|
||||||
|
{
|
||||||
|
// Exponential backoff
|
||||||
|
const MIN_DURATION: u64 = 60 * 2;
|
||||||
|
const MAX_DURATION: u64 = 60 * 60;
|
||||||
|
if continue_exponential_backoff_secs(
|
||||||
|
MIN_DURATION,
|
||||||
|
MAX_DURATION,
|
||||||
|
time.elapsed(),
|
||||||
|
*tries,
|
||||||
|
) {
|
||||||
|
debug_warn!(
|
||||||
|
tried = ?*tries,
|
||||||
|
elapsed = ?time.elapsed(),
|
||||||
|
"Backing off from {next_id}",
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if events_all.contains(&next_id) {
|
if events_all.contains(&next_id) {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue