8000 Add checksum newtype by simolus3 · Pull Request #80 · powersync-ja/powersync-sqlite-core · GitHub
[go: up one dir, main page]

Skip to content
Add checksum newtype #80
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

Merged
merged 2 commits into from
Jun 2, 2025
Merged

Add checksum newtype #80

merged 2 commits into from
Jun 2, 2025

Conversation

simolus3
Copy link
Contributor

I'm moving some independent parts out of #70 to make that easier to review and understand.

This adds a Checksum newtype wrapping a u32, making the way we deal with checksum computations a little easier to understand:

  1. Checksum implements the + and - operators modulo 2³². This is the behavior we want, and avoids issues if we forget a wrapping_add or wrapping_sub call somewhere.
  2. It centralizes the fact that checksums are u32 types. We've previously been using i32 (which doesn't make a difference for addition and subtraction), but this makes it clearer that checksums are unsigned types that need to be explicitly cast from i32 where necessary.
  3. This moves some sync-related files into a sync submodule.

@simolus3 simolus3 requested a review from rkistner May 30, 2025 07:18
rkistner
rkistner previously approved these changes May 30, 2025
Copy link
Contributor
@rkistner rkistner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this approach.

Could we also add one or two tests for the wrapping add/subtract behavior?

@simolus3 simolus3 merged commit afb5da2 into main Jun 2, 2025
21 checks passed
@simolus3 simolus3 deleted the checksum-type branch June 2, 2025 10:22
@simolus3 simolus3 mentioned this pull request Jun 11, 2025
10 tasks
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
0