Skip to content

Commit

Permalink
fix breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasad1 committed Oct 24, 2024
1 parent d7629b2 commit 6ca53b4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 0 additions & 2 deletions prdoc/pr_5741.prdoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,3 @@ crates:
bump: major
- name: sc-rpc-server
bump: patch
- name: sc-service
bump: major
17 changes: 16 additions & 1 deletion substrate/client/rpc-spec-v2/src/chain_head/chain_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ pub struct ChainHeadConfig {
/// Stop all subscriptions if the distance between the leaves and the current finalized
/// block is larger than this value.
pub max_lagging_distance: usize,
/// The maximum number of items reported by the `chainHead_storage` before
/// pagination is required.
pub operation_max_storage_items: usize,
/// The maximum number of `chainHead_follow` subscriptions per connection.
pub max_follow_subscriptions_per_connection: usize,
}
Expand All @@ -99,6 +102,10 @@ const MAX_LAGGING_DISTANCE: usize = 128;
/// The maximum number of `chainHead_follow` subscriptions per connection.
const MAX_FOLLOW_SUBSCRIPTIONS_PER_CONNECTION: usize = 4;

/// The maximum number of items the `chainHead_storage` can return
/// before paginations is required.
const MAX_STORAGE_ITER_ITEMS: usize = 5;

impl Default for ChainHeadConfig {
fn default() -> Self {
ChainHeadConfig {
Expand All @@ -107,6 +114,7 @@ impl Default for ChainHeadConfig {
subscription_max_ongoing_operations: MAX_ONGOING_OPERATIONS,
max_lagging_distance: MAX_LAGGING_DISTANCE,
max_follow_subscriptions_per_connection: MAX_FOLLOW_SUBSCRIPTIONS_PER_CONNECTION,
operation_max_storage_items: MAX_STORAGE_ITER_ITEMS,
}
}
}
Expand All @@ -124,6 +132,9 @@ pub struct ChainHead<BE: Backend<Block>, Block: BlockT, Client> {
/// Stop all subscriptions if the distance between the leaves and the current finalized
/// block is larger than this value.
max_lagging_distance: usize,
/// The maximum number of items reported by the `chainHead_storage` before
/// pagination is required.
operation_max_storage_items: usize,
/// Phantom member to pin the block type.
_phantom: PhantomData<Block>,
}
Expand All @@ -148,6 +159,7 @@ impl<BE: Backend<Block>, Block: BlockT, Client> ChainHead<BE, Block, Client> {
backend,
),
max_lagging_distance: config.max_lagging_distance,
operation_max_storage_items: config.operation_max_storage_items,
_phantom: PhantomData,
}
}
Expand Down Expand Up @@ -423,7 +435,10 @@ where
Err(_) => return ResponsePayload::error(ChainHeadRpcError::InvalidBlock),
};

let mut storage_client = ChainHeadStorage::<Client, Block, BE>::new(self.client.clone());
let mut storage_client = ChainHeadStorage::<Client, Block, BE>::new(
self.client.clone(),
self.operation_max_storage_items
);

let (rp, rp_fut) = method_started_response(block_guard.operation().operation_id());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl<Client, Block, BE> Clone for ChainHeadStorage<Client, Block, BE> {

impl<Client, Block, BE> ChainHeadStorage<Client, Block, BE> {
/// Constructs a new [`ChainHeadStorage`].
pub fn new(client: Arc<Client>) -> Self {
pub fn new(client: Arc<Client>, _operation_max_storage_items: usize) -> Self {
Self { client: Storage::new(client), _phandom: PhantomData }
}
}
Expand Down

0 comments on commit 6ca53b4

Please sign in to comment.