diff --git a/explorer/adapter.cpp b/explorer/adapter.cpp index 08ed40129..1ea65eda9 100644 --- a/explorer/adapter.cpp +++ b/explorer/adapter.cpp @@ -2209,11 +2209,13 @@ class Adapter : public Node::IObserver, public IAdapter { void OnHdrs_SizeCompressed_Rel(json& j) { j.push_back(MakeTableHdr("D.Size.Compressed")); } void OnHdrs_SizeCompressed_Rel(json& j, const Totals& t1, const Totals& t0, const Block::SystemState::Full& s) { j.push_back(MakeDecimalDelta(get_ChainSize(s.m_Height, t1, false) - get_ChainSize(s.m_Height - 1, t0, false)).m_sz); } - json get_hdrs(uint64_t hMax, uint64_t nMax, uint32_t fAbs, uint32_t fRel) override + json get_hdrs(uint64_t hMax, uint64_t nMax, uint64_t dh, uint32_t fAbs, uint32_t fRel) override { std::setmin(nMax, 2048u); std::setmin(hMax, _nodeBackend.m_Cursor.m_Full.m_Height); + std::setmax(dh, 1u); + json jRet = json::array(); { @@ -2244,6 +2246,7 @@ class Adapter : public Node::IObserver, public IAdapter { sid.m_Row = db.FindActiveStateStrict(hMax); Merkle::Hash hv; + bool bValidHv = false; StateData pTots[2]; uint32_t iIdxTots = 0; @@ -2254,7 +2257,7 @@ class Adapter : public Node::IObserver, public IAdapter { Block::SystemState::Full s; db.get_State(sid.m_Row, s); - if (hMax == sid.m_Height) + if (!bValidHv) s.get_Hash(hv); json jRow = json::array(); @@ -2267,7 +2270,17 @@ class Adapter : public Node::IObserver, public IAdapter { iIdxTots = !iIdxTots; - if (!db.get_Prev(sid)) + if (sid.m_Height - Rules::HeightGenesis >= dh) + { + if (1u == dh) + db.get_Prev(sid); + else + { + sid.m_Height -= dh; + sid.m_Row = db.FindActiveStateStrict(sid.m_Height); + } + } + else { ZeroObject(sid); bDone = true; @@ -2296,7 +2309,11 @@ class Adapter : public Node::IObserver, public IAdapter { if (bDone) break; - hv = s.m_Prev; + if (1u == dh) + { + hv = s.m_Prev; + bValidHv = true; + } } } diff --git a/explorer/adapter.h b/explorer/adapter.h index 5d57c7b39..1115e424b 100644 --- a/explorer/adapter.h +++ b/explorer/adapter.h @@ -72,7 +72,7 @@ struct IAdapter { virtual json get_block(uint64_t height) = 0; virtual json get_block_by_kernel(const Blob& key) = 0; virtual json get_blocks(uint64_t startHeight, uint64_t n) = 0; - virtual json get_hdrs(uint64_t hMax, uint64_t nMax, uint32_t fAbs, uint32_t fRel) = 0; + virtual json get_hdrs(uint64_t hMax, uint64_t nMax, uint64_t dh, uint32_t fAbs, uint32_t fRel) = 0; virtual json get_peers() = 0; #ifdef BEAM_ATOMIC_SWAP_SUPPORT diff --git a/explorer/server.cpp b/explorer/server.cpp index 3cc2dff41..b49d33398 100644 --- a/explorer/server.cpp +++ b/explorer/server.cpp @@ -804,6 +804,7 @@ OnRequest(hdrs) { Height hTop = _currentUrl.get_int_arg("hMax", std::numeric_limits::max()); uint32_t n = (uint32_t) _currentUrl.get_int_arg("nMax", static_cast(-1)); + Height dh = _currentUrl.get_int_arg("dh", static_cast(1)); // defaults typedef IAdapter::TotalsFlags F; @@ -813,7 +814,7 @@ OnRequest(hdrs) ReadColFlags(_currentUrl, fAbs, "cabs"); ReadColFlags(_currentUrl, fRel, "crel"); - return _backend.get_hdrs(hTop, n, fAbs, fRel); + return _backend.get_hdrs(hTop, n, dh, fAbs, fRel); } OnRequest(peers)