Skip to content

Commit

Permalink
Vladik7 (#1977)
Browse files Browse the repository at this point in the history
* explorer_node: assets method fix (minor).

* Output: move c'tor instead of partial copy c'tor

* explorer: changed sorting for block ins/outs
  • Loading branch information
valdok authored May 29, 2024
1 parent afbf31f commit 978af20
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 8 deletions.
5 changes: 4 additions & 1 deletion core/block_crypt.h
Original file line number Diff line number Diff line change
Expand Up @@ -689,10 +689,13 @@ namespace beam
{
}

Output(const Output& o)
Output(Output&& o)
:TxElement(o)
,m_Coinbase(o.m_Coinbase)
,m_Incubation(o.m_Incubation)
,m_pConfidential(std::move(o.m_pConfidential))
,m_pPublic(std::move(o.m_pPublic))
,m_pAsset(std::move(o.m_pAsset))
{
}

Expand Down
64 changes: 58 additions & 6 deletions explorer/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2065,14 +2065,27 @@ class Adapter : public Node::IObserver, public IAdapter {
MakeTableHdr("Metadata")
}));


bool bCurrent = (h >= _nodeBackend.m_Cursor.m_Full.m_Height);

Asset::Full ai;
for (ai.m_ID = 1; ; ai.m_ID++)
for (ai.m_ID = 0; ; )
{
int ret = _nodeBackend.get_AssetAt(ai, h);
if (!ret)
break;
if (ret < 0)
continue;
if (bCurrent)
{
if (!_nodeBackend.get_DB().AssetGetNext(ai))
break;
}
else
{
++ai.m_ID;
int ret = _nodeBackend.get_AssetAt(ai, h);
if (!ret)
break;

if (ret < 0)
continue;
}

ExtraInfo::Writer wr(json::array());
wr.m_json.push_back(MakeObjAid(ai.m_ID));
Expand Down Expand Up @@ -2337,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 @@ -2436,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
2 changes: 1 addition & 1 deletion explorer/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ OnRequest(asset)

OnRequest(assets)
{
auto height = _currentUrl.get_int_arg("height", 0);
auto height = _currentUrl.get_int_arg("height", MaxHeight);
return _backend.get_assets_at(height);
}

Expand Down

0 comments on commit 978af20

Please sign in to comment.