Add NetQuery::add_verification_prefix.

This commit is contained in:
levlam 2024-05-09 22:16:52 +03:00
parent 25d1bf6466
commit d5ac68c067
2 changed files with 14 additions and 0 deletions

View File

@ -171,4 +171,15 @@ StringBuilder &operator<<(StringBuilder &stream, const NetQueryPtr &net_query_pt
return stream << *net_query_ptr;
}
void NetQuery::add_verification_prefix(const string &prefix) {
CHECK(is_ready());
CHECK(is_error());
CHECK(!query_.empty());
BufferSlice query(prefix.size() + query_.size() - verification_prefix_length_);
query.as_mutable_slice().copy_from(prefix);
query.as_mutable_slice().substr(prefix.size()).copy_from(query_.as_slice().substr(verification_prefix_length_));
verification_prefix_length_ = narrow_cast<int32>(prefix.size());
query_ = std::move(query);
}
} // namespace td

View File

@ -238,6 +238,8 @@ class NetQuery final : public TsListNode<NetQueryDebug> {
return in_sequence_dispacher_;
}
void add_verification_prefix(const string &prefix);
private:
State state_ = State::Empty;
Type type_ = Type::Common;
@ -251,6 +253,7 @@ class NetQuery final : public TsListNode<NetQueryDebug> {
BufferSlice query_;
BufferSlice answer_;
int32 tl_constructor_ = 0;
int32 verification_prefix_length_ = 0;
vector<NetQueryRef> invoke_after_;
vector<uint64> chain_ids_;