refactor: Open file in FileCommit #28006

pull maflcko wants to merge 3 commits into bitcoin:master from maflcko:2306-fs-stuff- changing 6 files +34 −45
  1. maflcko commented at 6:03 pm on June 29, 2023: member

    This improves FileCommit: The patch removes the requirement from the call site to open or obtain a raw C-style FILE pointer. Now the call site can use any style of file IO.

    There are many other smaller improvements, which are explained in each commit.

  2. DrahtBot commented at 6:03 pm on June 29, 2023: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #26654 (util: Show descriptive error messages when FileCommit fails by john-moffett)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  3. DrahtBot renamed this:
    refactor: Open file in FileCommit
    refactor: Open file in FileCommit
    on Jun 29, 2023
  4. DrahtBot added the label Refactoring on Jun 29, 2023
  5. maflcko force-pushed on Jun 29, 2023
  6. maflcko force-pushed on Jun 29, 2023
  7. DrahtBot added the label CI failed on Jun 29, 2023
  8. maflcko force-pushed on Jun 29, 2023
  9. DrahtBot removed the label CI failed on Jun 29, 2023
  10. maflcko commented at 5:46 am on June 30, 2023: member
    Closing for now, until there is a higher need for it.
  11. maflcko closed this on Jun 30, 2023

  12. maflcko deleted the branch on Jun 30, 2023
  13. maflcko restored the branch on Jul 20, 2023
  14. maflcko commented at 6:50 am on July 20, 2023: member
    Looks like this will make it safer to remove std::ftell when using XOR, so I’ll reopen for now as draft.
  15. maflcko reopened this on Jul 20, 2023

  16. maflcko marked this as a draft on Jul 20, 2023
  17. DrahtBot added the label Needs rebase on Jul 20, 2023
  18. DrahtBot commented at 1:01 pm on July 20, 2023: contributor

    🐙 This pull request conflicts with the target branch and needs rebase.

  19. refactor: Remove std::FILE* where not needed
    This is needed for a future commit.
    afe59293b8
  20. refactor: use fs::resize_file in ResizeFile
    This allows to remove platform-specific code and avoids it being
    maintained in this codebase.
    
    This is a refactor, apart from potentially using one more file
    descriptor at runtime, due to the same file being opened already
    earlier. However, the increase in file descriptors will be undone in the
    next commit.
    e1b98e40f5
  21. refactor: Open file in FileCommit
    * This removes the requirement from the call site to use a raw C-style
      FILE pointer. Now the call site can use any style of file IO.
    * This makes the edge-case impossible to call FileCommit with nullptr,
      which would eventually lead to a segfault.
    * This removes the burden from the call site to first open the file.
    * This avoids a fseek if the file was opened using FlatFileSeq::Open
      with a non-zero nPos.
    * Where the file was already open at a call site, it removes the burden
      to keep it open for FileCommit. Call sites are now expected to close
      or flush the file before calling FileCommit.
    * This removes the requirement from the call site to open the file with
      the right mode (write).
    
    This should be a refactor, because the following corner cases never happen:
    * FlatFileSeq::Open has a side-effect to create the file when it is
      missing. Thus, in WriteFilterToDisk, if the first filter overflew the
      first file, the node would abort. Previously it would create an empty
      first filter file.
    4d8d2f1b61
  22. maflcko force-pushed on Jul 20, 2023
  23. maflcko commented at 7:20 pm on July 20, 2023: member
    Closing for now.
  24. maflcko closed this on Jul 20, 2023

  25. maflcko deleted the branch on Jul 20, 2023
  26. bitcoin locked this on Jul 19, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-04 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me