Make the skip lists self-decsriptive. This change will cause old and new servers to diverge ledgers.

This commit is contained in:
JoelKatz
2012-11-08 14:36:15 -08:00
parent 3ada064342
commit 5cb35b7a8f
3 changed files with 12 additions and 0 deletions

View File

@@ -1077,13 +1077,17 @@ void Ledger::updateSkipList()
std::vector<uint256> hashes;
if (!skipList)
{
skipList = boost::make_shared<SLE>(ltLEDGER_HASHES, hash);
skipList->setFieldU32(sfFirstLedgerSequence, prevIndex);
}
else
hashes = skipList->getFieldV256(sfHashes).peekValue();
assert(hashes.size() <= 256);
hashes.push_back(mParentHash);
skipList->setFieldV256(sfHashes, STVector256(hashes));
skipList->setFieldU32(sfLastLedgerSequence, prevIndex);
if (writeBack(lepCREATE, skipList) == lepERROR)
{
@@ -1096,7 +1100,10 @@ void Ledger::updateSkipList()
SLE::pointer skipList = getSLE(hash);
std::vector<uint256> hashes;
if (!skipList)
{
skipList = boost::make_shared<SLE>(ltLEDGER_HASHES, hash);
skipList->setFieldU32(sfFirstLedgerSequence, prevIndex);
}
else
hashes = skipList->getFieldV256(sfHashes).peekValue();
@@ -1105,6 +1112,7 @@ void Ledger::updateSkipList()
hashes.erase(hashes.begin());
hashes.push_back(mParentHash);
skipList->setFieldV256(sfHashes, STVector256(hashes));
skipList->setFieldU32(sfLastLedgerSequence, prevIndex);
if (writeBack(lepCREATE, skipList) == lepERROR)
{

View File

@@ -86,6 +86,8 @@ static bool LEFInit()
;
DECLARE_LEF(LedgerHashes, ltLEDGER_HASHES)
<< SOElement(sfFirstLedgerSequence, SOE_OPTIONAL)
<< SOElement(sfLastLedgerSequence, SOE_OPTIONAL)
<< SOElement(sfHashes, SOE_REQUIRED)
;

View File

@@ -55,6 +55,8 @@
FIELD(BondAmount, UINT32, 23)
FIELD(LoadFee, UINT32, 24)
FIELD(OfferSequence, UINT32, 25)
FIELD(FirstLedgerSequence, UINT32, 26)
FIELD(LastLedgerSequence, UINT32, 27)
// 64-bit integers
FIELD(IndexNext, UINT64, 1)