Skip to content

Commit

Permalink
securedht: use onConnect callback
Browse files Browse the repository at this point in the history
  • Loading branch information
aberaud committed Apr 15, 2021
1 parent d3fc755 commit 55c5953
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/securedht.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,18 @@ SecureDht::SecureDht(std::unique_ptr<DhtInterface> dht, SecureDht::Config conf,
if (key_ and certId != key_->getPublicKey().getId())
throw DhtException("SecureDht: provided certificate doesn't match private key.");

dht_->put(certId, Value {
CERTIFICATE_TYPE,
*certificate_,
1
}, [this, certId](bool ok) {
if (iacb_) iacb_(ok);
if (ok)
if (logger_)
logger_->d(certId, "SecureDht: public key announced successfully");
}, {}, true);
dht_->addOnConnectedCallback([&]{
dht_->put(certId, Value {
CERTIFICATE_TYPE,
*certificate_,
1
}, [this, certId](bool ok) {
if (iacb_) iacb_(ok);
if (ok)
if (logger_)
logger_->d(certId, "SecureDht: public key announced successfully");
}, {}, true);
});
}
}

Expand Down

0 comments on commit 55c5953

Please sign in to comment.