f5a5ebb204
Replace per-transaction CTxIndex spent tracking with per-output UTXO database (CUtxoEntry). ConnectBlock writes/erases UTXOs as blocks are processed. FetchInputs reads directly from UTXO DB instead of deserializing full transactions from disk. Persist nChainTrust in block index (dbformat v3) to skip expensive recalculation on every startup. Only populate setStakeSeen for last 500 blocks instead of all 2M+. Lazy fallback to old CTxIndex path for databases upgrading from pre-UTXO format - no big-bang migration required. Fixes pre-existing bugs in introdialog.cpp (extra brace) and net_bootstrap.cpp (namespace extern). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
45 lines
1.2 KiB
C++
45 lines
1.2 KiB
C++
// Copyright (c) 2024 Triangles developers
|
|
// Network Bootstrap Implementation for Triangles
|
|
// Distributed under the MIT/X11 software license
|
|
|
|
#include "net_bootstrap.h"
|
|
#include "main.h"
|
|
#include "net.h"
|
|
#include "util.h"
|
|
|
|
namespace NetBootstrap {
|
|
|
|
NetworkHealth GetNetworkHealth() {
|
|
NetworkHealth health;
|
|
health.connectedPeers = 0;
|
|
health.torPeers = 0;
|
|
health.isBootstrapped = false;
|
|
health.isSyncing = false;
|
|
health.lastBlockTime = 0;
|
|
|
|
// Count connected peers
|
|
{
|
|
LOCK(cs_vNodes);
|
|
health.connectedPeers = vNodes.size();
|
|
|
|
for (CNode* pnode : vNodes) {
|
|
std::string addr = pnode->addr.ToString();
|
|
if (addr.find(".onion") != std::string::npos) {
|
|
health.torPeers++;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Bootstrapped if at least 3 connections
|
|
health.isBootstrapped = (health.connectedPeers >= 3);
|
|
|
|
// Sync status (nTimeBestReceived declared in main.h)
|
|
health.isSyncing = (::nTimeBestReceived > 0 &&
|
|
GetTime() - ::nTimeBestReceived < 3600);
|
|
health.lastBlockTime = ::nTimeBestReceived;
|
|
|
|
return health;
|
|
}
|
|
|
|
} // namespace NetBootstrap
|