Skip to content

refactor(gl): extract Arweave discovery loop from clone.rs to cut file size and enable unit tests #71

@beardthelion

Description

@beardthelion

Surfaced during review of #70 (#49). Maintainability only, no behavior change.

crates/gl/src/clone.rs was already over 1000 lines before #70 (1154) and is now ~1665. The review deferred the cleanup to keep #70 focused; tracking it here.

Three seams, in rough priority:

  1. Extract the Arweave discovery loop in recover_from_arweave into a standalone async fn discover_tx_refs(client, ag, slug) -> (Vec<TxRef>, /* incomplete */ bool). Beyond shrinking the function, this makes the pagination bounds (page cap, id cap, non-advancing-cursor guard) unit-testable directly. Today those paths only have integration coverage, and the degenerate-cursor test can't cleanly isolate "guard fired" from "mock exhausted" because the loop is inline and only reachable through a full mockito + git scaffold.

  2. Deduplicate the blob-install logic. The git hash-object -w write plus the oid-match verify is duplicated almost verbatim between recover_encrypted_blobs and recover_from_arweave. Pull it into a private install_blob(dest_str, oid, plaintext) -> Result<bool>.

  3. Move the Arweave types out. TxRef, TxPage, parse_tx_page, height_rank, merge_manifests, and the discovery loop are self-contained and could live in a sibling module (e.g. crates/gl/src/clone/arweave.rs).

Goal: behavior-preserving refactor that brings clone.rs back under ~1000 lines and makes the discovery bounds unit-testable. Existing tests stay green; no functional change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions