diff options
| author | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-23 12:54:05 +0000 |
|---|---|---|
| committer | DanConwayDev <DanConwayDev@protonmail.com> | 2026-02-23 12:54:05 +0000 |
| commit | 84c9003323162f166552d1dea15ee9ed1b1a025a (patch) | |
| tree | 1ce3707903d0d9a26c09eef26190b855445cd0be /src | |
| parent | f659ac657bbce1aec423815c184255bb50652ba3 (diff) | |
feat: extend purgatory announcement expiry when state event arrives
Per design doc decision #4: state event arrival resets the 30-minute
protocol timer for purgatory announcements. This prevents premature
expiry during slow sync operations where the repo is actively receiving
metadata but git data hasn't arrived yet.
Extends expiry for all owners whose announcement authorized the state
event, and triggers revival if the announcement was soft-expired.
Diffstat (limited to 'src')
| -rw-r--r-- | src/nostr/policy/state.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/nostr/policy/state.rs b/src/nostr/policy/state.rs index 9ad72c2..e6de54e 100644 --- a/src/nostr/policy/state.rs +++ b/src/nostr/policy/state.rs | |||
| @@ -146,6 +146,34 @@ impl StatePolicy { | |||
| 146 | "State event author authorized via maintainer set" | 146 | "State event author authorized via maintainer set" |
| 147 | ); | 147 | ); |
| 148 | 148 | ||
| 149 | // Extend expiry for any purgatory announcements for this identifier. | ||
| 150 | // | ||
| 151 | // Per design doc decision #4: state event arrival extends the purgatory | ||
| 152 | // announcement's expiry (reset the 30-minute protocol timer). This prevents | ||
| 153 | // premature expiry during slow sync operations — the repo is actively receiving | ||
| 154 | // metadata so it should stay alive. | ||
| 155 | // | ||
| 156 | // We extend for all owners that authorized this state event, since the state | ||
| 157 | // event proves the repo is active regardless of which owner's announcement | ||
| 158 | // authorized it. | ||
| 159 | for owner_hex in &authorized_owners { | ||
| 160 | if let Ok(owner_pk) = nostr_sdk::PublicKey::from_hex(owner_hex) { | ||
| 161 | if self.ctx.purgatory.has_purgatory_announcement(&owner_pk, &state.identifier) { | ||
| 162 | self.ctx.purgatory.extend_announcement_expiry( | ||
| 163 | &owner_pk, | ||
| 164 | &state.identifier, | ||
| 165 | std::time::Duration::from_secs(1800), | ||
| 166 | ); | ||
| 167 | tracing::debug!( | ||
| 168 | event_id = %event.id, | ||
| 169 | identifier = %state.identifier, | ||
| 170 | owner = %owner_hex, | ||
| 171 | "Extended purgatory announcement expiry due to state event arrival" | ||
| 172 | ); | ||
| 173 | } | ||
| 174 | } | ||
| 175 | } | ||
| 176 | |||
| 149 | // Duplicate check in db | 177 | // Duplicate check in db |
| 150 | if db_repo_data.states.iter().any(|e| e.event.id.eq(&event.id)) { | 178 | if db_repo_data.states.iter().any(|e| e.event.id.eq(&event.id)) { |
| 151 | tracing::debug!("processed state event duplicate (in db): {}", event.id); | 179 | tracing::debug!("processed state event duplicate (in db): {}", event.id); |