mirror of
https://github.com/block/buzz.git
synced 2026-11-01 06:51:17 +00:00
desktop: retire conflicted aggregate attempts
Delete an exact pending edit attempt after a proven relay conflict so the next edit can advance from newly hydrated authority instead of being blocked by a dead retained generation. Co-authored-by: Carl <c7ebe626f000404285d3686e1dc74cc07cc60a9754a150041ba132e14bd3e2ec@buzz.block.builderlab.xyz> Signed-off-by: Wes <wesbillman@users.noreply.github.com>
This commit is contained in:
@@ -940,7 +940,7 @@ pub async fn update_managed_agent(
|
||||
let conn = crate::managed_agents::retention::open_retention_db(
|
||||
&scope.db_path,
|
||||
)?;
|
||||
if !crate::managed_agents::retention::mark_managed_agent_aggregate_synced(
|
||||
if !crate::managed_agents::retention::retire_managed_agent_aggregate(
|
||||
&conn,
|
||||
&pending.owner_pubkey,
|
||||
&pending.agent_pubkey,
|
||||
|
||||
@@ -131,6 +131,24 @@ pub struct RetainedManagedAgentAggregate {
|
||||
pub local_authority_applied: bool,
|
||||
}
|
||||
|
||||
pub fn retire_managed_agent_aggregate(
|
||||
conn: &Connection,
|
||||
owner_pubkey: &str,
|
||||
agent_pubkey: &str,
|
||||
generation: u64,
|
||||
private_event_id: &str,
|
||||
) -> Result<bool, String> {
|
||||
let changed = conn
|
||||
.execute(
|
||||
"DELETE FROM managed_agent_aggregates
|
||||
WHERE owner_pubkey = ?1 AND agent_pubkey = ?2
|
||||
AND generation = ?3 AND private_event_id = ?4 AND pending_sync = 1",
|
||||
params![owner_pubkey, agent_pubkey, generation as i64, private_event_id],
|
||||
)
|
||||
.map_err(|error| format!("failed to retire managed-agent aggregate: {error}"))?;
|
||||
Ok(changed == 1)
|
||||
}
|
||||
|
||||
pub fn seed_confirmed_managed_agent_aggregate(
|
||||
conn: &Connection,
|
||||
aggregate: &RetainedManagedAgentAggregate,
|
||||
|
||||
Reference in New Issue
Block a user