Properly wait for public key of minidump upload address.
This commit is contained in:
parent
e4a1390f2e
commit
f0b4525901
@ -116,13 +116,13 @@ namespace Components
|
|||||||
else
|
else
|
||||||
for (auto& addr : Singleton->BMClient->PubAddresses)
|
for (auto& addr : Singleton->BMClient->PubAddresses)
|
||||||
{
|
{
|
||||||
Logger::Print("%s\n", addr.getAddress().c_str());
|
Logger::Print("%s (waiting for public key: %s)\n", addr.getAddress().c_str(), addr.waitingPubKey() ? "yes" : "no");
|
||||||
}
|
}
|
||||||
|
|
||||||
mlock.unlock();
|
mlock.unlock();
|
||||||
});
|
});
|
||||||
Command::Add("bm_save", [](Command::Params) {
|
Command::Add("bm_save", [](Command::Params) {
|
||||||
Singleton->BMClient->save(BITMESSAGE_OBJECT_STORAGE_FILENAME);
|
Singleton->Save();
|
||||||
});
|
});
|
||||||
Command::Add("bm_address_public", [](Command::Params params) {
|
Command::Add("bm_address_public", [](Command::Params params) {
|
||||||
if (params.Length() < 2) return;
|
if (params.Length() < 2) return;
|
||||||
@ -187,6 +187,31 @@ namespace Components
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool BitMessage::RequestAndWaitForPublicKey(std::string targetAddress)
|
||||||
|
{
|
||||||
|
// Convert to ustring
|
||||||
|
ustring targetAddressU;
|
||||||
|
targetAddressU.fromString(targetAddress);
|
||||||
|
|
||||||
|
// Convert to PubAddr
|
||||||
|
PubAddr pubAddr;
|
||||||
|
if (!pubAddr.loadAddr(targetAddressU))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request public key!
|
||||||
|
this->BMClient->getPubKey(pubAddr);
|
||||||
|
|
||||||
|
// TODO: Wait for public key by using signalling in BitMRC, needs to be done directly in the fork.
|
||||||
|
do
|
||||||
|
{
|
||||||
|
sleep(1000);
|
||||||
|
} while (pubAddr.waitingPubKey());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool BitMessage::Subscribe(std::string targetAddress)
|
bool BitMessage::Subscribe(std::string targetAddress)
|
||||||
{
|
{
|
||||||
// Convert to ustring
|
// Convert to ustring
|
||||||
@ -256,6 +281,11 @@ namespace Components
|
|||||||
BMClient->addAddr(myAddress);
|
BMClient->addAddr(myAddress);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BitMessage::Save()
|
||||||
|
{
|
||||||
|
BMClient->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -19,9 +19,11 @@ namespace Components
|
|||||||
|
|
||||||
void SetDefaultTTL(time_t ttl);
|
void SetDefaultTTL(time_t ttl);
|
||||||
bool RequestPublicKey(std::string targetAddress);
|
bool RequestPublicKey(std::string targetAddress);
|
||||||
|
bool RequestAndWaitForPublicKey(std::string targetAddress);
|
||||||
bool Subscribe(std::string targetAddress);
|
bool Subscribe(std::string targetAddress);
|
||||||
bool SendMsg(std::string targetAddress, std::string message, time_t ttl = 0);
|
bool SendMsg(std::string targetAddress, std::string message, time_t ttl = 0);
|
||||||
bool SendBroadcast(std::string message, time_t ttl = 0);
|
bool SendBroadcast(std::string message, time_t ttl = 0);
|
||||||
|
void Save();
|
||||||
|
|
||||||
static BitMessage* Singleton;
|
static BitMessage* Singleton;
|
||||||
BitMRC* BMClient;
|
BitMRC* BMClient;
|
||||||
|
@ -216,10 +216,12 @@ namespace Components
|
|||||||
{
|
{
|
||||||
#ifndef DISABLE_BITMESSAGE
|
#ifndef DISABLE_BITMESSAGE
|
||||||
// Preload public key for our target that will receive minidumps
|
// Preload public key for our target that will receive minidumps
|
||||||
if (!BitMessage::Singleton->RequestPublicKey(MinidumpUpload::targetAddress))
|
Logger::Print("Waiting for public key for minidump upload address.\n");
|
||||||
|
if (!BitMessage::Singleton->RequestAndWaitForPublicKey(MinidumpUpload::targetAddress))
|
||||||
{
|
{
|
||||||
Logger::Error("Failed to request public key for minidump collection address.\n");
|
Logger::Error("Failed to request public key for minidump collection address.\n");
|
||||||
}
|
}
|
||||||
|
BitMessage::Singleton->Save();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check if folder exists
|
// Check if folder exists
|
||||||
|
Loading…
Reference in New Issue
Block a user