forked from pi-apps/stellar-core
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmainnet_governor.cpp
More file actions
36 lines (32 loc) · 1.28 KB
/
Copy pathmainnet_governor.cpp
File metadata and controls
36 lines (32 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "mainnet_governor.h"
#include <chrono>
#include <ctime>
MainnetGovernor::MainnetGovernor() : mainnetLaunched_(false) {}
bool MainnetGovernor::auditEcosystemTransactions(const std::vector<std::vector<Transaction>>& ecosystemTxs) {
bool allCompliant = true;
for (size_t i = 0; i < ecosystemTxs.size(); ++i) {
for (const auto& tx : ecosystemTxs[i]) {
if (!validator_.validate(tx)) {
allCompliant = false;
auditLog_.push_back("Non-compliant transaction detected in component " + std::to_string(i));
}
}
}
auto now = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
auditLog_.push_back("Audit completed at " + std::string(std::ctime(&now)) + " Compliance: " + (allCompliant ? "YES" : "NO"));
return allCompliant;
}
bool MainnetGovernor::launchMainnet(const std::vector<std::vector<Transaction>>& ecosystemTxs) {
if (mainnetLaunched_) {
return false; // Already launched
}
if (!auditEcosystemTransactions(ecosystemTxs)) {
return false; // Abort launch
}
mainnetLaunched_ = true;
auditLog_.push_back("Mainnet launched successfully.");
return true;
}
const std::vector<std::string>& MainnetGovernor::getAuditLog() const {
return auditLog_;
}