mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 00:28:01 +00:00
Refactor and fix usage of get_session_index() and get_session_info_by_index() (#4735)
* Rename/refactor around get_session_index Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * choose proper head for fetching session Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * revert rename Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix comments Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * renaming and more comments Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * review feedback Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Run Fetch task in correct session Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Log warning when ancestors unavailable Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * Fixes Signed-off-by: Andrei Sandu <andrei-mihail@parity.io> * fix Signed-off-by: Andrei Sandu <andrei-mihail@parity.io>
This commit is contained in:
@@ -102,7 +102,7 @@ impl RollingSessionWindow {
|
||||
window_size: SessionWindowSize,
|
||||
block_hash: Hash,
|
||||
) -> Result<Self, SessionsUnavailable> {
|
||||
let session_index = get_session_index_for_head(ctx, block_hash).await?;
|
||||
let session_index = get_session_index_for_child(ctx, block_hash).await?;
|
||||
|
||||
let window_start = session_index.saturating_sub(window_size.get() - 1);
|
||||
|
||||
@@ -160,7 +160,7 @@ impl RollingSessionWindow {
|
||||
ctx: &mut (impl SubsystemContext + overseer::SubsystemContext),
|
||||
block_hash: Hash,
|
||||
) -> Result<SessionWindowUpdate, SessionsUnavailable> {
|
||||
let session_index = get_session_index_for_head(ctx, block_hash).await?;
|
||||
let session_index = get_session_index_for_child(ctx, block_hash).await?;
|
||||
|
||||
let old_window_start = self.earliest_session;
|
||||
|
||||
@@ -212,7 +212,12 @@ impl RollingSessionWindow {
|
||||
}
|
||||
}
|
||||
|
||||
async fn get_session_index_for_head(
|
||||
// Returns the session index expected at any child of the `parent` block.
|
||||
//
|
||||
// Note: We could use `RuntimeInfo::get_session_index_for_child` here but it's
|
||||
// cleaner to just call the runtime API directly without needing to create an instance
|
||||
// of `RuntimeInfo`.
|
||||
async fn get_session_index_for_child(
|
||||
ctx: &mut (impl SubsystemContext + overseer::SubsystemContext),
|
||||
block_hash: Hash,
|
||||
) -> Result<SessionIndex, SessionsUnavailable> {
|
||||
|
||||
Reference in New Issue
Block a user