Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

Add Equatable and Hashable to Transaction types - #968

Merged
gemcoder21 merged 1 commit into
mainfrom
add-transaction-extended-equatable
Feb 23, 2026
Merged

gemcoder21 merged 1 commit into
mainfrom
add-transaction-extended-equatable

Conversation

@DRadmir

@DRadmir DRadmir commented Feb 23, 2026

Copy link
Copy Markdown
Contributor
  • TransactionUtxoInput: add Hashable
  • Transaction: add Hashable
  • TransactionExtended: add Equatable, Hashable

- TransactionUtxoInput: add Hashable
- Transaction: add Hashable
- TransactionExtended: add Equatable, Hashable
@DRadmir DRadmir self-assigned this Feb 23, 2026
@semanticdiff-com

semanticdiff-com Bot commented Feb 23, 2026 •

Copy link
Copy Markdown

Review changes with  SemanticDiff

Changed Files
File Status
  crates/primitives/src/transaction.rs  0% smaller
  crates/primitives/src/transaction_extended.rs  0% smaller
  crates/primitives/src/transaction_utxo.rs  0% smaller

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @DRadmir, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the Transaction related data structures by adding Equatable and Hashable protocol conformance for their Swift representations. This change improves the utility of these types by allowing them to be compared for equality and used in hash-based data structures, which is crucial for efficient data management and collection operations in Swift applications.

Highlights

  • TransactionUtxoInput: The TransactionUtxoInput struct now implements the Hashable protocol in Swift, enabling it to be used in hash-based collections.
  • Transaction: The Transaction struct now implements the Hashable protocol in Swift, allowing for consistent hashing and use in sets or as dictionary keys.
  • TransactionExtended: The TransactionExtended struct now implements both Equatable and Hashable protocols in Swift, providing full support for equality comparisons and hashing.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • crates/primitives/src/transaction.rs
    • Added Hashable to the typeshare attribute for the Transaction struct.
  • crates/primitives/src/transaction_extended.rs
    • Added Equatable and Hashable to the typeshare attribute for the TransactionExtended struct.
  • crates/primitives/src/transaction_utxo.rs
    • Added Hashable to the typeshare attribute for the TransactionUtxoInput struct.
Activity
  • No human activity has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

The pull request successfully implements the addition of Hashable to Transaction and TransactionUtxoInput, and Equatable, Hashable to TransactionExtended as described. However, for TransactionExtended and TransactionUtxoInput, there are potential maintainability issues due to a mismatch between the derived Rust traits and the typeshare Swift traits. It is recommended to align the Rust derive attributes with the typeshare declarations for consistency and predictable behavior.


#[derive(Debug, Clone, Serialize, Deserialize)]
#[typeshare(swift = "Sendable")]
#[typeshare(swift = "Sendable, Equatable, Hashable")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The TransactionExtended struct is marked with typeshare(swift = "Sendable, Equatable, Hashable"), implying that the Swift type will conform to Equatable and Hashable. However, the Rust struct does not derive PartialEq or Hash. For consistency and to ensure correct behavior in Swift, it's best practice to derive PartialEq, Eq, and Hash for the Rust struct when its Swift counterpart is Equatable and Hashable.

Consider adding PartialEq, Eq, and Hash to the derive attribute for TransactionExtended.

Suggested change
#[typeshare(swift = "Sendable, Equatable, Hashable")]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]


#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[typeshare(swift = "Sendable, Equatable")]
#[typeshare(swift = "Sendable, Equatable, Hashable")]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The TransactionUtxoInput struct is marked with typeshare(swift = "Sendable, Equatable, Hashable"), implying that the Swift type will conform to Hashable. While PartialEq is already derived, Hash and Eq are missing from the Rust derive attributes. For consistency and to ensure correct hashing behavior in Swift, it's best practice to derive Eq and Hash for the Rust struct when its Swift counterpart is Hashable.

Consider adding Eq and Hash to the derive attribute for TransactionUtxoInput.

Suggested change
#[typeshare(swift = "Sendable, Equatable, Hashable")]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]

@gemcoder21
gemcoder21 merged commit 99d3d7c into main Feb 23, 2026
4 checks passed
@gemcoder21
gemcoder21 deleted the add-transaction-extended-equatable branch February 23, 2026 19:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants