Skip to content

Commit

Permalink
explorer: changed sorting for block ins/outs
Browse files Browse the repository at this point in the history
  • Loading branch information
valdok committed May 29, 2024
1 parent ca00ebc commit e3d679a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions explorer/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -2449,6 +2475,19 @@ class Adapter : public Node::IObserver, public IAdapter {
std::vector<NodeProcessor::TxoInfo> 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)
{
Expand Down

0 comments on commit e3d679a

Please sign in to comment.