Skip to content

Commit

Permalink
Allow unlimited catchain.getBlock requests (ton-blockchain#1132)
Browse files Browse the repository at this point in the history
  • Loading branch information
SpyCheese authored Aug 28, 2024
1 parent e9bd482 commit 48d94d5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion catchain/catchain-receiver-source.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CatChainReceiverSource {
virtual td::BufferSlice fork_proof() const = 0;
virtual bool fork_is_found() const = 0;

// One block can be sent to one node only a limited number of times to prevent DoS
// One block can be sent to one node in catchain.getDifference only a limited number of times to prevent DoS
virtual bool allow_send_block(CatChainBlockHash hash) = 0;

static td::Result<std::unique_ptr<CatChainReceiverSource>> create(CatChainReceiver *chain, PublicKey pub_key,
Expand Down
8 changes: 2 additions & 6 deletions catchain/catchain-receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,12 +697,8 @@ void CatChainReceiverImpl::process_query(adnl::AdnlNodeIdShort src, ton_api::cat
} else {
CatChainReceiverSource *S = get_source_by_adnl_id(src);
CHECK(S != nullptr);
if (S->allow_send_block(it->second->get_hash())) {
promise.set_value(serialize_tl_object(create_tl_object<ton_api::catchain_blockResult>(it->second->export_tl()),
true, it->second->get_payload().as_slice()));
} else {
promise.set_error(td::Status::Error("block was requested too many times"));
}
promise.set_value(serialize_tl_object(create_tl_object<ton_api::catchain_blockResult>(it->second->export_tl()),
true, it->second->get_payload().as_slice()));
}
}

Expand Down

0 comments on commit 48d94d5

Please sign in to comment.