dhtrunner: unpack value

This commit is contained in:
Adrien Béraud committed 2015-08-14 21:37:51 -04:00
1 parent 73c53cc0ec
commit d5ff0e2187
2 files changed
+6 -2

No files matched your search

+4 -2
View File
@@ -86,7 +86,8 @@ public:
get(hash, [=](const std::vector<std::shared_ptr<Value>>& vals) {
for (const auto& v : vals) {
try {
auto msg = unpack<T>(v->data);
T msg;
msg.unpackValue(*v);
if (not cb(std::move(msg)))
return false;
} catch (const std::exception&) {
@@ -145,7 +146,8 @@ public:
return listen(hash, [=](const std::vector<std::shared_ptr<Value>>& vals) {
for (const auto& v : vals) {
try {
auto msg = unpack<T>(v->data);
T msg;
msg.unpackValue(*v);
if (not cb(std::move(msg)))
return false;
} catch (const std::exception&) {
+2
View File
@@ -369,6 +369,8 @@ SecureDht::decrypt(const Value& v)
auto msg = msgpack::unpack((const char*)decrypted.data(), decrypted.size());
ret.msgpack_unpack_body(msg.get());
if (ret.recipient != getId())
throw crypto::DecryptError("Recipient mismatch");
if (not ret.owner.checkSignature(ret.getToSign(), ret.signature))
throw crypto::DecryptError("Signature mismatch");