aboutsummaryrefslogtreecommitdiffhomepage
path: root/tde2e/td/e2e/Call.cpp
diff options
context:
space:
mode:
authorArseny Smirnov <arseny30@gmail.com>2025-04-11 13:31:29 +0400
committerArseny Smirnov <arseny30@gmail.com>2025-04-11 13:31:29 +0400
commit7dfe60f100f4d840dca4faf71991da2f918ed2d4 (patch)
treeccca1f95cf6a1d245336e27c915a2e5e6362387e /tde2e/td/e2e/Call.cpp
parentaefd7826f762e03b1375f6c60b23d642d67d0210 (diff)
e2e: return error it client tries to resuse the same private key for different calls
Diffstat (limited to 'tde2e/td/e2e/Call.cpp')
-rw-r--r--tde2e/td/e2e/Call.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/tde2e/td/e2e/Call.cpp b/tde2e/td/e2e/Call.cpp
index c467329c8..dca0e3459 100644
--- a/tde2e/td/e2e/Call.cpp
+++ b/tde2e/td/e2e/Call.cpp
@@ -571,6 +571,15 @@ td::Result<std::string> Call::create_self_add_block(const PrivateKey &private_ke
}
td::Result<Call> Call::create(td::int64 user_id, PrivateKey private_key, td::Slice last_block_server) {
+ {
+ // Forbid creating multiple calls with the same key
+ static std::mutex mutex;
+ static td::FlatHashSet<td::UInt256, UInt256Hash> public_keys;
+ std::lock_guard<std::mutex> lock(mutex);
+ if (!public_keys.insert(private_key.to_public_key().to_u256()).second) {
+ return Error(E::CallKeyAlreadyUsed);
+ }
+ }
TRY_RESULT(last_block, Blockchain::from_server_to_local(last_block_server.str()));
TRY_RESULT(blockchain, ClientBlockchain::create_from_block(last_block, private_key.to_public_key()));
auto call = Call(user_id, std::move(private_key), std::move(blockchain));