Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,12 @@ impl Client {
// Space => Outpoint mapping will be removed
// since this type of revocation only happens when an
// expired space is being re-opened for auction.
// No bids here so only remove Outpoint -> Spaceout
// Remove both Space -> Outpoint and Outpoint -> Spaceout mappings
if let Some(space) = update.output.spaceout.space.as_ref() {
let base_hash = Sha256::hash(space.name.as_ref());
let space_key = SpaceKey::from(base_hash);
state.remove(space_key);
}
let hash =
OutpointKey::from_outpoint::<Sha256>(update.output.outpoint());
state.remove(hash);
Expand Down
17 changes: 13 additions & 4 deletions client/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,19 @@ impl ChainState for LiveSnapshot {
if let Some(outpoint) = outpoint {
let spaceout = self.get_spaceout(&outpoint)?;

return Ok(Some(FullSpaceOut {
txid: outpoint.txid,
spaceout: spaceout.expect("should exist if outpoint exists"),
}));
// Handle data inconsistency gracefully: if outpoint exists but spaceout doesn't,
// this indicates the space was revoked but the space->outpoint mapping wasn't cleaned up.
// Clean up the inconsistent mapping and return None instead of panicking.
if let Some(spaceout) = spaceout {
return Ok(Some(FullSpaceOut {
txid: outpoint.txid,
spaceout,
}));
} else {
// Clean up the inconsistent space->outpoint mapping
self.remove(*space_hash);
return Ok(None);
}
}
Ok(None)
}
Expand Down
16 changes: 12 additions & 4 deletions protocol/src/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,18 @@ impl SpaceScript {
let existing = src.get_space_outpoint(&spacehash)?;
match existing {
None => OpenHistory::NewSpace(name.to_owned()),
Some(outpoint) => OpenHistory::ExistingSpace(FullSpaceOut {
txid: outpoint.txid,
spaceout: src.get_spaceout(&outpoint)?.expect("spaceout exists"),
}),
Some(outpoint) => {
// Handle data inconsistency: if spaceout doesn't exist, treat as new space
// This can happen if the space was revoked but the space->outpoint mapping
// wasn't cleaned up properly
match src.get_spaceout(&outpoint)? {
Some(spaceout) => OpenHistory::ExistingSpace(FullSpaceOut {
txid: outpoint.txid,
spaceout,
}),
None => OpenHistory::NewSpace(name.to_owned()),
}
}
}
};
let open = Ok(kind);
Expand Down
Loading