Module near_primitives::shard_layout
source · Structs
- A shard layout that maps accounts evenly across all shards – by calculate the hash of account id and mod number of shards. This is added to capture the old
account_id_to_shard_id
algorithm, to keep backward compatibility for some existing tests.parent_shards
forShardLayoutV1
is alwaysNone
, meaning it can only be the first shard layout a chain uses. - ShardUId is an unique representation for shards from different shard layout
Enums
Functions
- 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, accounts are divided to ranges, each range of account is mapped to a shard. There are also some fixed shards, each of which is mapped to an account and all sub-accounts. For example, for ShardLayoutV1{ fixed_shards: [“aurora”], boundary_accounts: [“near”]} Account “aurora” and all its sub-accounts will be mapped to shard_id 0. For the rest of accounts, accounts <= “near” will be mapped to shard_id 1 and accounts > “near” will be mapped shard_id 2.
- Maps an account to the shard that it belongs to given a shard_layout
- Returns the byte representation for (block, shard_uid)
- Deserialize from a byte representation to (block, shard_uid)
Type Definitions
- This file implements two data structure
ShardLayout
andShardUId