Skip to content

Reuse existing content outputs by hash instead of re-inscribing #2

Description

@shruggr

Problem

Before a file is inscribed, nothing checks whether identical bytes already exist on chain. The cascade only reuses outputs within a repository's own history: it compares each file against the previous root's snapshot by path and cites the old outpoint when the bytes match (src/cascade.ts). The same bytes under a different path, in a fork, or in another repository get inscribed again.

The wallet does not keep the zero-sat content outputs either (they are unspendable data outputs, not basketed), so there is no local record to consult.

Proposal

Keep a local index keyed by content hash (the git blob sha is already computed for every file in src/tree.ts; sha256 would also work) mapping to the outpoint that carries those bytes. Populate it whenever the CLI publishes or fetches content, and consult it in the cascade before planning a new file output, citing the existing outpoint the same way the fork path does.

This is a wallet-side/CLI concern. The gib overlay only tracks commit heads, not files, so no server change is needed for the first version. A cross-user lookup through the overlay could come later.

Notes

  • Same mechanism would apply to the SDK's ORDFS writer (buildOrdFsDirOutputs), possibly as an optional lookup hook, but nothing in the SDK is required for the CLI version.
  • Reused outputs must still be reachable by the resolver from the new root (cites are 36-byte outpoints, so this is already how forks work).

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions