...
 
Commits (2)
......@@ -12,11 +12,13 @@ namespace iota {
namespace tanglescope {
namespace statscollector {
static constexpr uint32_t MAX_CONFIRMED_BUNDLES_TO_KEEP = 10000;
void TXAnalyzer::newTransaction(std::shared_ptr<iri::TXMessage> msg) {
std::lock_guard guard(_mutex);
// Check if bundle has been confirmed already.
if (_confirmedBundles.find(msg->bundle()) != _confirmedBundles.end()) {
if (std::find(_confirmedBundles.begin(),_confirmedBundles.end(),msg->bundle()) != _confirmedBundles.end()) {
VLOG(7) << "onNewTransaction(bundle: " << msg->bundle()
<< ") already confirmed";
_stats->trackReattachedTX(_counters);
......@@ -58,7 +60,7 @@ void TXAnalyzer::transactionConfirmed(std::shared_ptr<iri::SNMessage> msg) {
const auto entry = _unconfirmedBundles.find(msg->bundle());
if (_confirmedBundles.find(msg->bundle()) != _confirmedBundles.end() ||
if (std::find(_confirmedBundles.begin(),_confirmedBundles.end(),msg->bundle()) != _confirmedBundles.end() ||
!_unconfirmedBundles.count(msg->bundle())) {
// Confirmed already or we haven't seen this bundle before and thus are
// ignoring it on purpose.
......@@ -94,6 +96,10 @@ void TXAnalyzer::transactionConfirmed(std::shared_ptr<iri::SNMessage> msg) {
_histograms);
_unconfirmedBundles.erase(entry);
_confirmedBundles.push_back(msg->bundle());
if (_confirmedBundles.size() > MAX_CONFIRMED_BUNDLES_TO_KEEP){
_confirmedBundles.pop_front();
}
}
} // namespace statscollector
} // namespace tanglescope
......
......@@ -4,6 +4,7 @@
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <list>
#include <chrono>
#include <cstdint>
......@@ -39,7 +40,7 @@ class TXAnalyzer {
private:
std::shared_mutex _mutex;
std::unordered_set<std::string> _confirmedBundles;
std::list<std::string> _confirmedBundles;
std::unordered_map<std::string, std::vector<std::shared_ptr<iri::TXMessage>>>
_unconfirmedBundles;
......