Skip to content

solana-account: add AccountSharedData::data_clone method#10

Merged
jstarry merged 1 commit intoanza-xyz:masterfrom
jstarry:feat/account-data-clone
Feb 10, 2025
Merged

solana-account: add AccountSharedData::data_clone method#10
jstarry merged 1 commit intoanza-xyz:masterfrom
jstarry:feat/account-data-clone

Conversation

@jstarry
Copy link
Copy Markdown
Contributor

@jstarry jstarry commented Feb 8, 2025

In order to create a lightweight view struct (anza-xyz/agave#4834) over vote account data without creating another copy of the data, I need to copy the internal Arc which is private.

@jstarry jstarry enabled auto-merge (squash) February 8, 2025 09:08
@jstarry jstarry disabled auto-merge February 8, 2025 09:08
@jstarry jstarry requested a review from joncinque February 8, 2025 09:22
Copy link
Copy Markdown
Collaborator

@joncinque joncinque left a comment

Choose a reason for hiding this comment

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

I looked for other patterns of cloning an internal Arc in a type to see if there's a standard way to name these kind of functions, but couldn't find anything in libraries like tokio / clap / std.

My one concern was that data_clone might make it sound like the underlying data is being cloned, but the return type should make that totally clear.

All in all, looks good!

@jstarry jstarry merged commit 59b5afd into anza-xyz:master Feb 10, 2025
@jstarry jstarry deleted the feat/account-data-clone branch February 10, 2025 12:08
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