Skip to content

Refactor export logic to separate module for better separation of concerns #6096

@coderabbitai

Description

@coderabbitai

Problem

Currently, the RPC layer directly uses CLI methods from the archive_cmd module, which violates separation of concerns principles. Specifically, the do_export function in src/tool/subcommands/archive_cmd.rs is being used by both:

  • CLI commands (forest-tool archive export)
  • RPC methods (Forest.ChainExportDiff)

Proposed Solution

Move the core export logic to a separate crate or dedicated module that can be shared between CLI and RPC layers without creating architectural dependencies.

This would involve:

  1. Extracting the core export functionality from archive_cmd.rs
  2. Creating a new module/crate for shared export logic
  3. Having both CLI and RPC layers depend on this shared module
  4. Maintaining clear separation between presentation layer (CLI/RPC) and business logic (export operations)

Context

This issue was identified during review of PR #6074 which adds forest-cli snapshot export-diff functionality.

References:

Benefits

  • Better architectural separation
  • Easier testing of core export logic
  • Reduced coupling between CLI and RPC layers
  • More maintainable codebase

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions