Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

改进 ProgressCheatBlocker #591

Merged
merged 1 commit into from
Oct 13, 2024
Merged

改进 ProgressCheatBlocker #591

merged 1 commit into from
Oct 13, 2024

Conversation

Ghost-chu
Copy link
Collaborator

@Ghost-chu Ghost-chu commented Oct 13, 2024

在之前的版本中,为了避免文件过小时计算文件下载进度时过于敏感导致误封的情况,在配置文件中定义了一个预设的大小 minimum-size 来控制小于此大小的 Torrent 将被完全跳过,这个默认值是 50MB。一旦种子文件大小小于此值,PeerBanHelper 就会完全跳过此 Torrent 的 ProgressCheatBlocker 检查代码。

此功能设计时,吸血情况远没有今天如此复杂。我们发现部分吸血端有时连较小的 Torrent 也没有放过。
此 PR 改进了 ProgressCheatBlocker 的代码。当 Torrent 小于 minimum-size 时,仅跳过部分检查,以下是更改前后的对比:

模块名称 更改前 更改后
超量下载 跳过 检查
进度回退 跳过 跳过
进度差异 跳过 跳过

Summary by CodeRabbit

  • New Features

    • Introduced a new method to check if torrent sizes are below a specified minimum threshold, enhancing peer management.
  • Bug Fixes

    • Updated conditions for banning peers to include checks for small torrent sizes, preventing unnecessary bans.

@Ghost-chu Ghost-chu requested a review from a team as a code owner October 13, 2024 07:54
Copy link
Contributor

coderabbitai bot commented Oct 13, 2024

Walkthrough

The ProgressCheatBlocker class in the peerbanhelper module has been modified to enhance peer management and data handling. A new method, fileTooSmall(long torrentSize), has been introduced to check if a torrent's size is below a minimum threshold. This method is integrated into the shouldBanPeer logic to streamline checks for banning peers based on torrent size, replacing direct size comparisons with calls to the new method. The updates improve code clarity by centralizing size validation and adjusting conditions for peer banning based on progress differences.

Changes

File Change Summary
src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ProgressCheatBlocker.java Added method fileTooSmall(long torrentSize) and updated shouldBanPeer logic to use this method for torrent size checks.

Possibly related PRs

  • PCB 作弊快速测试支持 #459: The changes in ProgressCheatBlocker.java and PeerBanHelperServer.java both relate to peer banning logic, indicating a connection in functionality regarding how peers are managed and banned based on their behavior.
  • 添加对 BitComet 的支持 (v2.10 Beta6 [20240928]+) #540: The modifications in ProgressCheatBlocker.java and the introduction of the BitComet class suggest a broader context of managing peers across different downloaders, including BitComet, which may involve similar peer management strategies.

Suggested reviewers

  • paulzzh

Poem

🐰 In the code where torrents flow,
A check for size now starts to grow.
No more bans for tiny files,
Just clearer paths and simpler miles.
With fileTooSmall, we hop with glee,
In our peer world, all will be free! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between fe8c632 and 1447cee.

📒 Files selected for processing (1)
  • src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ProgressCheatBlocker.java (4 hunks)
🧰 Additional context used
🔇 Additional comments (4)
src/main/java/com/ghostchu/peerbanhelper/module/impl/rule/ProgressCheatBlocker.java (4)

Line range hint 244-255: New fast PCB test logic aligns with PR objectives

The addition of the fastPcbTestPercentage check in the shouldBanPeer method correctly implements the fast progress cheat blocking test. By including !fileTooSmall(torrentSize), it ensures that this test is skipped for torrents smaller than the minimum size, which is consistent with the updated requirements to avoid unnecessary checks on small files.


Line range hint 281-289: Progress difference check appropriately excludes small torrents

The condition if (difference > maximumDifference && !fileTooSmall(torrentSize)) ensures that the progress difference checks are only performed on torrents larger than the minimum size. This change adheres to the PR objective of skipping progress difference checks for smaller torrents.


Line range hint 294-303: Rewind check modified to skip small torrents

By adding !fileTooSmall(torrentSize) to the rewind check condition, the code now correctly skips progress rewind checks for small torrents, aligning with the intended behavior described in the PR objectives.


321-324: Extraction of fileTooSmall method enhances code maintainability

The introduction of the fileTooSmall(long torrentSize) method centralizes the logic for checking if a torrent is below the minimum size. This improves code readability and maintainability by avoiding redundant size comparison code throughout the class.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

2 participants