Skip to content

Commit

Permalink
refactor: remove 'to' field from block request
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitriy Khaustov aka xDimon <khaustov.dm@gmail.com>
  • Loading branch information
xDimon committed Oct 20, 2022
1 parent 58b2272 commit 6379e55
Show file tree
Hide file tree
Showing 7 changed files with 0 additions and 40 deletions.
11 changes: 0 additions & 11 deletions core/network/adapters/protobuf_block_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ namespace kagome::network {
msg.set_number(&n, sizeof(n));
});

// Note: request.to is not used in substrate
if (t.to.has_value()) {
msg.set_to_block(t.to->toString());
}

msg.set_direction(static_cast<::api::v1::Direction>(t.direction));

if (t.max.has_value()) {
Expand Down Expand Up @@ -89,12 +84,6 @@ namespace kagome::network {
return AdaptersError::UNEXPECTED_VARIANT;
}

if (not msg.to_block().empty()) {
OUTCOME_TRY(to_block,
primitives::BlockHash::fromString(msg.to_block()));
out.to.emplace(to_block);
}

if (msg.max_blocks() > 0) {
out.max.emplace(msg.max_blocks());
}
Expand Down
8 changes: 0 additions & 8 deletions core/network/impl/protocols/sync_protocol_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,6 @@ namespace kagome::network {
logmsg += fmt::format(", from {}", from);
});

if (block_request.to.has_value()) {
logmsg += fmt::format(" to {}", block_request.to.value());
}

logmsg +=
block_request.direction == Direction::ASCENDING ? " anc" : " desc";

Expand Down Expand Up @@ -435,10 +431,6 @@ namespace kagome::network {
logmsg += fmt::format(" from {}", from);
});

if (block_request.to.has_value()) {
logmsg += fmt::format(" to {}", block_request.to.value());
}

logmsg +=
block_request.direction == Direction::ASCENDING ? " anc" : " desc";

Expand Down
3 changes: 0 additions & 3 deletions core/network/impl/synchronizer_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@ namespace kagome::network {

network::BlocksRequest request{network::BlockAttribute::HEADER,
hint,
std::nullopt,
network::Direction::ASCENDING,
1};

Expand Down Expand Up @@ -592,7 +591,6 @@ namespace kagome::network {

network::BlocksRequest request{attributesForSync(sync_method_),
from.hash,
std::nullopt,
network::Direction::ASCENDING,
std::nullopt};

Expand Down Expand Up @@ -825,7 +823,6 @@ namespace kagome::network {
BlocksRequest request{
BlockAttribute::HEADER | BlockAttribute::JUSTIFICATION,
target_block.hash,
std::nullopt,
Direction::ASCENDING,
limit};

Expand Down
2 changes: 0 additions & 2 deletions core/network/protobuf/api.v1.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 0 additions & 8 deletions core/network/types/blocks_request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ namespace kagome::network {
BlockAttributes fields{};
/// start from this block
primitives::BlockId from{};
/// end at this block; an implementation defined maximum is used when
/// unspecified
std::optional<primitives::BlockHash> to{};
/// sequence direction
Direction direction{};
/// maximum number of blocks to return; an implementation defined maximum is
Expand Down Expand Up @@ -58,11 +55,6 @@ struct std::hash<kagome::network::BlocksRequest> {
boost::hash_combine(
result, std::hash<kagome::primitives::BlockId>()(blocks_request.from));

boost::hash_combine(
result,
std::hash<std::optional<kagome::primitives::BlockHash>>()(
blocks_request.to));

boost::hash_combine(
result,
std::hash<kagome::network::Direction>()(blocks_request.direction));
Expand Down
1 change: 0 additions & 1 deletion test/core/network/sync_protocol_observer_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ TEST_F(SynchronizerTest, ProcessRequest) {
// GIVEN
BlocksRequest received_request{BlocksRequest::kBasicAttributes,
block3_hash_,
std::nullopt,
Direction::ASCENDING,
std::nullopt};

Expand Down
7 changes: 0 additions & 7 deletions test/core/network/types/protobuf_block_request_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ struct ProtobufBlockRequestAdapterTest : public ::testing::Test {
BlockHash::fromHex("11111403ba5b6a3f3bd0b0604ce439a78244"
"c7d43b127ec35cd8325602dd47fd"));
request.from = hash_from;

EXPECT_OUTCOME_TRUE(
hash_to,
BlockHash::fromHex("22221403ba5b6a3f3bd0b0604ce439a78244"
"c7d43b127ec35cd8325602dd47fd"));
request.to = hash_to;
}

BlocksRequest request;
Expand All @@ -58,5 +52,4 @@ TEST_F(ProtobufBlockRequestAdapterTest, Serialization) {
ASSERT_EQ(r2.max, request.max);
ASSERT_EQ(r2.fields, request.fields);
ASSERT_EQ(r2.from, request.from);
ASSERT_EQ(r2.to, request.to);
}

0 comments on commit 6379e55

Please sign in to comment.