From e3d679acfcf66d91cc0ddf2efcb2798017d7328c Mon Sep 17 00:00:00 2001 From: valdok Date: Wed, 29 May 2024 15:14:53 +0300 Subject: [PATCH] explorer: changed sorting for block ins/outs --- explorer/adapter.cpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/explorer/adapter.cpp b/explorer/adapter.cpp index 18e57b184..af17db8c3 100644 --- a/explorer/adapter.cpp +++ b/explorer/adapter.cpp @@ -2350,6 +2350,32 @@ class Adapter : public Node::IObserver, public IAdapter { ok = false; } + struct CmpIn { + bool operator() (const NodeProcessor::TxoInfo& a, const NodeProcessor::TxoInfo& b) const { + if (a.m_hCreate < b.m_hCreate) + return true; + if (a.m_hCreate > b.m_hCreate) + return false; + if (a.m_Outp.get_MinMaturity(0) < b.m_Outp.get_MinMaturity(0)) + return true; + return false; + } + }; + std::stable_sort(vIns.begin(), vIns.end(), CmpIn()); + + struct CmpOut { + bool operator() (const NodeProcessor::TxoInfo& a, const NodeProcessor::TxoInfo& b) const { + if (a.m_hSpent < b.m_hSpent) + return true; + if (a.m_hSpent > b.m_hSpent) + return false; + if (a.m_Outp.get_MinMaturity(0) < b.m_Outp.get_MinMaturity(0)) + return true; + return false; + } + }; + std::stable_sort(vOuts.begin(), vOuts.end(), CmpOut()); + if (ok) { char buf[80]; @@ -2449,6 +2475,19 @@ class Adapter : public Node::IObserver, public IAdapter { std::vector vOuts; _nodeBackend.ExtractTreasurykWithExtra(vOuts); + struct CmpOut { + bool operator() (const NodeProcessor::TxoInfo& a, const NodeProcessor::TxoInfo& b) const { + if (a.m_Outp.m_Incubation < b.m_Outp.m_Incubation) + return true; + if (a.m_Outp.m_Incubation > b.m_Outp.m_Incubation) + return false; + if (a.m_hSpent < b.m_hSpent) + return true; + return false; + } + }; + std::stable_sort(vOuts.begin(), vOuts.end(), CmpOut()); + json outputs = json::array(); for (const auto& v : vOuts) {