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

refactor: Implement account_id_to_shard_id as a method in ShardLayout #12480

Open
wacban opened this issue Nov 19, 2024 · 2 comments
Open

refactor: Implement account_id_to_shard_id as a method in ShardLayout #12480

wacban opened this issue Nov 19, 2024 · 2 comments

Comments

@wacban
Copy link
Contributor

wacban commented Nov 19, 2024

Description

Today we use a function called account_id_to_shard_id in order to figure out what shard an account belongs to. It's a bit annoying to use. A better way would be to have it as a method in ShardLayout. This would be nicer since then the IDE can suggest this method when dealing with ShardLayout. It also seem more natural to have it as a method.

The goals of this issue are to:

  • Implement account_id_to_shard_id as a method in ShardLayout
  • Adjust the existing account_id_to_shard_id to simply called the ShardLayout::account_id_to_shard_id
  • Migrate a few usages of the old one to the new one.

There is no need to migrate all of the old usages as that may be annoying and of little learning value. It's fine to just do a few to show that it works.

reference:

/// Maps an account to the shard that it belongs to given a shard_layout
/// For V0, maps according to hash of account id
/// For V1 and V2, accounts are divided to ranges, each range of account is mapped to a shard.
///
/// TODO(wacban) This would be nicer as a method in ShardLayout
pub fn account_id_to_shard_id(account_id: &AccountId, shard_layout: &ShardLayout) -> ShardId {

@virajbhartiya
Copy link

Can I work on this?

@wacban
Copy link
Contributor Author

wacban commented Nov 19, 2024

@virajbhartiya Sorry, it's a ramp up task for someone else.

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

No branches or pull requests

2 participants