From 29237410580f9b21f62ae2d2f3b5ef2584aa825b Mon Sep 17 00:00:00 2001 From: "James C. Owens" Date: Sat, 10 Feb 2024 20:13:55 -0500 Subject: [PATCH] Add try/catch around calls to GetBeaconChainletRoot The catch for std::runtime_exception will assert, ensuring Gridcoin stops after resetting the beacon registry. --- src/gridcoin/tally.cpp | 6 +++++- src/rpc/mining.cpp | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gridcoin/tally.cpp b/src/gridcoin/tally.cpp index 024745761f..bd94e412db 100644 --- a/src/gridcoin/tally.cpp +++ b/src/gridcoin/tally.cpp @@ -1233,7 +1233,11 @@ CAmount Tally::GetNewbieSuperblockAccrualCorrection(const Cpid& cpid, const Supe // Walk back the entries in the historical beacon map linked by renewal prev tx hash until the first // beacon in the renewal chain is found (the original advertisement). The accrual starts no earlier // than here. - beacon_ptr = beacons.GetBeaconChainletRoot(beacon); + try { + beacon_ptr = beacons.GetBeaconChainletRoot(beacon); + } catch (std::runtime_error& e) { + assert(false); + } const CBlockIndex* pindex_baseline = GRC::Tally::GetBaseline(); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index e266f624cf..8a30d7e739 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -307,7 +307,11 @@ UniValue auditsnapshotaccrual(const UniValue& params, bool fHelp) UniValue beacon_chain(UniValue::VARR); - beacon_ptr = beacons.GetBeaconChainletRoot(beacon_ptr, beacon_chain_out_ptr); + try { + beacon_ptr = beacons.GetBeaconChainletRoot(beacon_ptr, beacon_chain_out_ptr); + } catch (std::runtime_error& e) { + assert(false); + } for (const auto& iter : *beacon_chain_out_ptr) { UniValue beacon_chain_entry(UniValue::VOBJ);