Skip to content

Require a writable store to build a SwapWriteStore - #411

Merged
folbricht merged 1 commit into
masterfrom
swapstore-writable
Sep 2, 2026
Merged

folbricht merged 1 commit into
masterfrom
swapstore-writable

Conversation

@folbricht

@folbricht folbricht commented Sep 2, 2026 •

Copy link
Copy Markdown
Owner

NewSwapWriteStore accepted a plain Store while StoreChunk asserted the wrapped store was a WriteStore. Handing it one that isn't compiled fine, constructed without complaint, and then died on the first write:

panic: interface conversion: desync.roStore is not desync.WriteStore: missing method StoreChunk

Taking a WriteStore makes that a compile error. Swap already refuses to replace a writable store with one that isn't, so between the two the assertion in StoreChunk now holds by construction, and it carries a comment saying so.

chunk-server already checked s.(desync.WriteStore) before wrapping, so this was never reachable from the command line — only through the library. It now passes the value the assertion produces instead of re-passing the interface.

API change: NewSwapWriteStore(Store) becomes NewSwapWriteStore(WriteStore). Any caller it breaks is a caller that would have panicked at runtime.

There are no tests: the fix is that the bad call no longer compiles, and any test for it would have to bypass the constructor to reconstruct the state the change removes.

NewSwapWriteStore took a plain Store while StoreChunk asserted the
wrapped store was a WriteStore. Building one around a store that isn't
compiled and constructed without complaint, then panicked on the first
write:

  panic: interface conversion: desync.roStore is not desync.WriteStore

Taking a WriteStore makes that a compile error. Swap already refuses to
replace a writable store with one that isn't, so the assertion in
StoreChunk now holds by construction.

The command line already checked the store was writable before wrapping
it, so this was only reachable through the library.
@folbricht
folbricht merged commit 627ab7f into master Sep 2, 2026
9 checks passed
@folbricht
folbricht deleted the swapstore-writable branch September 2, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ 换网址