Calculate deep offer quality

This commit is contained in:
Nik Bougalis
2015-02-28 13:28:54 -08:00
committed by Tom Ritchford
parent d082a0696d
commit 6c81ea846c
2 changed files with 14 additions and 9 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

@@ -45,32 +45,36 @@ BookTip::step ()
for(;;)
{
// See if there's an entry at or worse than current quality.
auto const page (
view().getNextLedgerIndex (m_book, m_end));
// See if there's an entry at or worse than current quality. Notice
// that the quality is encoded only in the index of the first page
// of a directory.
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;