mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-01 05:14:49 +00:00
Add get_pendings_shard_blocks
This commit is contained in:
parent
727353c054
commit
f8597d2965
@ -16,6 +16,7 @@
|
||||
- [`get_shard_latest_attesting_balance`](#get_shard_latest_attesting_balance)
|
||||
- [`get_shard_head`](#get_shard_head)
|
||||
- [`get_shard_ancestor`](#get_shard_ancestor)
|
||||
- [`get_pendings_shard_blocks`](#get_pendings_shard_blocks)
|
||||
- [Handlers](#handlers)
|
||||
- [`on_shard_block`](#on_shard_block)
|
||||
|
||||
@ -108,6 +109,31 @@ def get_shard_ancestor(store: Store, shard_store: ShardStore, root: Root, slot:
|
||||
return root
|
||||
```
|
||||
|
||||
#### `get_pendings_shard_blocks`
|
||||
|
||||
```python
|
||||
def get_pendings_shard_blocks(store: Store, shard_store: ShardStore) -> Sequence[ShardBlock]:
|
||||
"""
|
||||
Return the shard blocks branch that from shard head to beacon head.
|
||||
"""
|
||||
shard = shard_store.shard
|
||||
|
||||
beacon_head_root = get_head(store)
|
||||
beacon_head_state = store.block_states[beacon_head_root]
|
||||
latest_shard_block_root = beacon_head_state.shard_states[shard].latest_block_root
|
||||
|
||||
shard_head_root = get_shard_head(store, shard_store)
|
||||
root = shard_head_root
|
||||
shard_blocks = []
|
||||
while root != latest_shard_block_root:
|
||||
shard_block = shard_store.blocks[root]
|
||||
shard_blocks.append(shard_block)
|
||||
root = shard_block.shard_parent_root
|
||||
|
||||
shard_blocks.reverse()
|
||||
return shard_blocks
|
||||
```
|
||||
|
||||
### Handlers
|
||||
|
||||
#### `on_shard_block`
|
||||
|
Loading…
x
Reference in New Issue
Block a user