Skip to content

Conversation

@golddydev
Copy link
Collaborator

@golddydev golddydev commented Oct 9, 2025

Summary

This PR implements /epochs/{number}/blocks/{pool_id} endpoints. And store first_block_height and last_block_height to epoch_state for epoch's blocks distribution.

Changes

New Features

  • Epoch-based pool block queries: Implemented /epochs/{number}/blocks/{pool_id} endpoint to retrieve block hashes minted by a specific pool during an epoch
  • Block height tracking: Added first_block_height and last_block_height fields to EpochActivityMessage for epoch blocks distribution.

Implementation Details

  • Restructured block hash storage: Changed from HashMap<KeyHash, Vector<BlockHash>> to HashMap<KeyHash, OrdMap<u64, Vector<BlockHash>>> to index blocks by epoch
  • Updated get_pool_block_hashes: Now returns Result and aggregates blocks across all epochs
  • Added get_pool_block_hashes_by_epoch: New method to retrieve blocks for a specific epoch and pool

@golddydev golddydev marked this pull request as ready for review October 10, 2025 06:48
@golddydev golddydev linked an issue Oct 10, 2025 that may be closed by this pull request
Copy link
Collaborator

@lowhung lowhung left a comment

Choose a reason for hiding this comment

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

Just a very small nit, but nothing blocking :) well done!

/// First block time
pub first_block_time: u64,

/// First block height
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: these comments don't seem particularly necessary, since the variable names are quite clear. Is there a reason we need them? :3

first_block_time: u64,

// first block height
first_block_height: u64,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same nit applies here

Copy link
Collaborator

@whankinsiv whankinsiv left a comment

Choose a reason for hiding this comment

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

Looks good overall. The only change I would like to see is storing block numbers instead of block hashes in spo_state to reduce memory usage.

@whankinsiv
Copy link
Collaborator

All requested changes have been implemented. Merging.

@whankinsiv whankinsiv merged commit d722769 into main Oct 13, 2025
2 checks passed
@golddydev golddydev deleted the golddydev/epochs-blocks branch October 15, 2025 05:55
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.

Implement /epochs/{number}/blocks/{pool_id} endpoint

3 participants