Jul 5th update

This commit is contained in:
Ned Wright
2023-07-05 23:32:39 +00:00
parent 22f1a984aa
commit a59f079ef7
85 changed files with 2488 additions and 1754 deletions

View File

@@ -208,12 +208,14 @@ void ConfidenceCalculator::pullProcessedData(const std::vector<std::string>& fil
{
dbgTrace(D_WAAP) << "Fetching the confidence set object";
bool is_first_pull = true;
bool is_ok = false;
for (auto file : files)
{
ConfidenceFileDecryptor getConfFile;
bool res = sendObjectWithRetry(getConfFile,
I_Messaging::Method::GET,
getUri() + "/" + file);
is_ok |= res;
if (res && getConfFile.getConfidenceSet().ok())
{
mergeFromRemote(getConfFile.getConfidenceSet().unpack(), is_first_pull);
@@ -224,8 +226,8 @@ void ConfidenceCalculator::pullProcessedData(const std::vector<std::string>& fil
m_confidence_level = getConfFile.getConfidenceLevels().unpackMove();
}
}
// is_first_pull = false -> at least one file was downloaded and merged
if (is_first_pull) {
// is_ok = false -> no file was downloaded and merged
if (!is_ok) {
dbgError(D_WAAP_CONFIDENCE_CALCULATOR) << "Failed to get the remote state";
}
}

View File

@@ -151,9 +151,9 @@ void TrustedSourcesConfidenceCalculator::pullProcessedData(const std::vector<std
bool res = sendObjectWithRetry(getTrustFile,
I_Messaging::Method::GET,
getUri() + "/" + file);
pull_ok |= res;
if (res && getTrustFile.getTrustedLogs().ok()) {
mergeFromRemote(getTrustFile.getTrustedLogs().unpack());
pull_ok = true;
}
}
if (!pull_ok && !files.empty()) {

View File

@@ -101,6 +101,24 @@ inline unsigned char from_hex(unsigned char ch, bool &valid) {
return ch;
}
inline bool str_starts_with(const std::string& value, const std::string& prefix)
{
if (prefix.size() > value.size()) {
return false;
}
return value.compare(0, prefix.size(), prefix) == 0;
}
inline bool str_ends_with(const std::string& value, const std::string& ending)
{
if (ending.size() > value.size()) {
return false;
}
return value.compare(value.size() - ending.size(), ending.size(), ending) == 0;
}
template<class _IT>
_IT unquote_plus(_IT first, _IT last, bool decodeUrl=true, bool decodePlus=true) {
_IT result = first;