Calculate deep offer quality

This commit is contained in:
Nik Bougalis
2015-02-28 13:28:54 -08:00
parent 95973ba3e8
commit 0b45535061
2 changed files with 12 additions and 8 deletions

View File

@@ -44,6 +44,7 @@ private:
uint256 m_dir;
uint256 m_index;
SLE::pointer m_entry;
Quality m_quality;
LedgerView&
view() const noexcept
@@ -67,10 +68,10 @@ public:
return m_index;
}
Quality const
Quality const&
quality() const noexcept
{
return Quality (getQuality (m_dir));
return m_quality;
}
SLE::pointer const&

View File

@@ -28,6 +28,7 @@ BookTip::BookTip (LedgerView& view, BookRef book)
, m_valid (false)
, m_book (getBookBase (book))
, m_end (getQualityNext (m_book))
, m_quality ()
{
}
@@ -46,31 +47,33 @@ BookTip::step ()
for(;;)
{
// See if there's an entry at or worse than current quality.
auto const page (
view().getNextLedgerIndex (m_book, m_end));
auto const first_page (view().getNextLedgerIndex (m_book, m_end));
if (page.isZero())
if (first_page.isZero())
return false;
unsigned int di (0);
SLE::pointer dir;
if (view().dirFirst (page, dir, di, m_index))
if (view().dirFirst (first_page, dir, di, m_index))
{
m_dir = dir->getIndex();
m_entry = view().entryCache (ltOFFER, m_index);
m_quality = Quality (getQuality (first_page));
m_valid = true;
// Next query should start before this directory
m_book = page;
m_book = first_page;
// The quality immediately before the next quality
--m_book;
break;
}
// There should never be an empty directory but just in case,
// we handle that case by advancing to the next directory.
m_book = page;
m_book = first_page;
}
return true;