Skip to content

Commit

Permalink
explorer node: added "Age" col in hdrs view
Browse files Browse the repository at this point in the history
  • Loading branch information
valdok committed Oct 19, 2024
1 parent cc56815 commit fd05b38
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
23 changes: 22 additions & 1 deletion explorer/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,22 @@ class Adapter : public Node::IObserver, public IAdapter {
get_TreasuryTotals(sd.m_Totals);
}

Timestamp m_tsBlock1 = 0;

Timestamp get_TimeStampGenesis()
{
if (!m_tsBlock1 && (_nodeBackend.m_Cursor.m_Full.m_Height >= Rules::HeightGenesis))
{
Block::SystemState::Full s;
auto row = _nodeBackend.FindActiveAtStrict(Rules::HeightGenesis);
_nodeBackend.get_DB().get_State(row, s);

m_tsBlock1 = s.m_TimeStamp;
}

return m_tsBlock1;
}

void EnsureHaveCumulativeStats(bool bForceReset = false)
{
auto& proc = _node.get_Processor();
Expand Down Expand Up @@ -2169,7 +2185,12 @@ class Adapter : public Node::IObserver, public IAdapter {
void OnName_Time_Abs() { m_json.push_back(MakeTableHdr("Timestamp")); }
void OnName_Time_Rel() { m_json.push_back(MakeTableHdr("d.Time")); }
void OnData_Time_Abs() { m_json.push_back(MakeTypeObj("time", m_pThis->m_Hdr.m_TimeStamp)); }
void OnData_Time_Rel() { m_json.push_back(m_This.MakeDecimalDelta(m_pThis->m_Hdr.m_TimeStamp - m_pPrev->m_Hdr.m_TimeStamp).m_sz);; }
void OnData_Time_Rel() { m_json.push_back(m_This.MakeDecimalDelta(m_pThis->m_Hdr.m_TimeStamp - m_pPrev->m_Hdr.m_TimeStamp).m_sz); }

void OnName_Age_Abs() { m_json.push_back(MakeTableHdr("Age")); }
void OnName_Age_Rel() { m_json.push_back(MakeTableHdr("d.Age")); }
void OnData_Age_Abs() { m_json.push_back(m_This.MakeDecimalDelta(m_pThis->m_Hdr.m_TimeStamp - m_This.get_TimeStampGenesis()).m_sz); }
void OnData_Age_Rel() { OnData_Time_Rel(); }

void OnName_Difficulty_Abs() { m_json.push_back(MakeTableHdr("Chainwork")); }
void OnName_Difficulty_Rel() { m_json.push_back(MakeTableHdr("Difficulty")); }
Expand Down
1 change: 1 addition & 0 deletions explorer/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ using nlohmann::json;

#define ExplorerTotals_All(macro) \
macro(Time) \
macro(Age) \
macro(Hash) \
macro(Difficulty) \
macro(Fee) \
Expand Down
1 change: 1 addition & 0 deletions explorer/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@ OnRequest(hdrs)

case 'H': val = C::Hash_Abs; break;
COL_CASE('T', 't', Time)
COL_CASE('G', 'g', Age)
COL_CASE('D', 'd', Difficulty)
COL_CASE('F', 'f', Fee)
COL_CASE('K', 'k', Kernels)
Expand Down

0 comments on commit fd05b38

Please # to comment.