From 4a6c7aaf5ba0d507f4dc6234a0886b1bc374b877 Mon Sep 17 00:00:00 2001 From: Pierre Krieger <pierre.krieger1708@gmail.com> Date: Sat, 8 Oct 2022 23:15:25 +0200 Subject: [PATCH] Remove "to_block" field from BlockRequests (#12447) * Remove "to_block" field from BlockRequests * Maybe fix the tests --- substrate/client/network/common/src/sync/message.rs | 2 -- substrate/client/network/sync/src/lib.rs | 9 +-------- substrate/client/network/sync/src/schema/api.v1.proto | 2 -- substrate/client/network/sync/src/warp.rs | 1 - 4 files changed, 1 insertion(+), 13 deletions(-) diff --git a/substrate/client/network/common/src/sync/message.rs b/substrate/client/network/common/src/sync/message.rs index 27ab2704e64..db9f747108c 100644 --- a/substrate/client/network/common/src/sync/message.rs +++ b/substrate/client/network/common/src/sync/message.rs @@ -158,8 +158,6 @@ pub mod generic { pub fields: BlockAttributes, /// Start from this block. pub from: FromBlock<Hash, Number>, - /// End at this block. An implementation defined maximum is used when unspecified. - pub to: Option<Hash>, /// Sequence direction. pub direction: Direction, /// Maximum number of blocks to return. An implementation defined maximum is used when diff --git a/substrate/client/network/sync/src/lib.rs b/substrate/client/network/sync/src/lib.rs index 6ad4a8fbbdc..63484903511 100644 --- a/substrate/client/network/sync/src/lib.rs +++ b/substrate/client/network/sync/src/lib.rs @@ -650,7 +650,6 @@ where id: 0, fields: BlockAttributes::JUSTIFICATION, from: FromBlock::Hash(request.0), - to: None, direction: Direction::Ascending, max: Some(1), }; @@ -1608,7 +1607,6 @@ where FromBlock::Number(n) => Some(schema::v1::block_request::FromBlock::Number(n.encode())), }, - to_block: request.to.map(|h| h.encode()).unwrap_or_default(), direction: request.direction as i32, max_blocks: request.max.unwrap_or(0), support_multiple_justifications: true, @@ -2252,7 +2250,6 @@ fn ancestry_request<B: BlockT>(block: NumberFor<B>) -> BlockRequest<B> { id: 0, fields: BlockAttributes::HEADER | BlockAttributes::JUSTIFICATION, from: FromBlock::Number(block), - to: None, direction: Direction::Ascending, max: Some(1), } @@ -2368,7 +2365,6 @@ fn peer_block_request<B: BlockT>( id: 0, fields: attrs, from, - to: None, direction: Direction::Descending, max: Some((range.end - range.start).saturated_into::<u32>()), }; @@ -2402,7 +2398,6 @@ fn peer_gap_block_request<B: BlockT>( id: 0, fields: attrs, from, - to: None, direction: Direction::Descending, max: Some((range.end - range.start).saturated_into::<u32>()), }; @@ -2452,7 +2447,6 @@ fn fork_sync_request<B: BlockT>( id: 0, fields: attributes, from: FromBlock::Hash(*hash), - to: None, direction: Direction::Descending, max: Some(count), }, @@ -2702,8 +2696,7 @@ mod test { assert!(sync.justification_requests().any(|(p, r)| { p == peer_id3 && r.fields == BlockAttributes::JUSTIFICATION && - r.from == FromBlock::Hash(b1_hash) && - r.to == None + r.from == FromBlock::Hash(b1_hash) })); assert_eq!( diff --git a/substrate/client/network/sync/src/schema/api.v1.proto b/substrate/client/network/sync/src/schema/api.v1.proto index b51137d1d51..203b157470a 100644 --- a/substrate/client/network/sync/src/schema/api.v1.proto +++ b/substrate/client/network/sync/src/schema/api.v1.proto @@ -23,8 +23,6 @@ message BlockRequest { // Start with given block number. bytes number = 3; } - // End at this block. An implementation defined maximum is used when unspecified. - bytes to_block = 4; // optional // Sequence direction. Direction direction = 5; // Maximum number of blocks to return. An implementation defined maximum is used when unspecified. diff --git a/substrate/client/network/sync/src/warp.rs b/substrate/client/network/sync/src/warp.rs index 4f2a71d9861..ab8a7c66b98 100644 --- a/substrate/client/network/sync/src/warp.rs +++ b/substrate/client/network/sync/src/warp.rs @@ -193,7 +193,6 @@ where fields: BlockAttributes::HEADER | BlockAttributes::BODY | BlockAttributes::JUSTIFICATION, from: FromBlock::Hash(header.hash()), - to: Some(header.hash()), direction: Direction::Ascending, max: Some(1), }; -- GitLab