mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
Logic to 'rebase' a ledger to a different previous ledger.
This code does not assume the new previous ledger is valid or trusted. 1) Validate sequence numbers and basic information. 2) Create a new ledger based on the new previous ledger. 3) Compare the old previous ledger and the new previous ledger. 4) Try to include any missing, valid transactions in the current ledger. 5) Traverse the old ledger based on the old previous ledger, try to import any transactions into the new ledger.
This commit is contained in:
@@ -274,12 +274,10 @@ Transaction::pointer Transaction::findFrom(const uint160& fromID, uint32 seq)
|
||||
}
|
||||
|
||||
bool Transaction::convertToTransactions(uint32 firstLedgerSeq, uint32 secondLedgerSeq,
|
||||
bool checkFirstTransactions, bool checkSecondTransactions,
|
||||
const std::map<uint256, std::pair<SHAMapItem::pointer, SHAMapItem::pointer> >& inMap,
|
||||
bool checkFirstTransactions, bool checkSecondTransactions, const SHAMap::SHAMapDiff& inMap,
|
||||
std::map<uint256, std::pair<Transaction::pointer, Transaction::pointer> >& outMap)
|
||||
{ // convert a straight SHAMap payload difference to a transaction difference table
|
||||
// return value: true=ledgers are valid, false=a ledger is invalid
|
||||
bool ret=true;
|
||||
std::map<uint256, std::pair<SHAMapItem::pointer, SHAMapItem::pointer> >::const_iterator it;
|
||||
for(it=inMap.begin(); it!=inMap.end(); ++it)
|
||||
{
|
||||
@@ -294,7 +292,7 @@ bool Transaction::convertToTransactions(uint32 firstLedgerSeq, uint32 secondLedg
|
||||
if( (firstTrans->getStatus()==INVALID) || (firstTrans->getID()!=id) )
|
||||
{
|
||||
firstTrans->setStatus(INVALID, firstLedgerSeq);
|
||||
ret=false;
|
||||
return false;
|
||||
}
|
||||
else firstTrans->setStatus(INCLUDED, firstLedgerSeq);
|
||||
}
|
||||
@@ -305,17 +303,17 @@ bool Transaction::convertToTransactions(uint32 firstLedgerSeq, uint32 secondLedg
|
||||
if( (secondTrans->getStatus()==INVALID) || (secondTrans->getID()!=id) )
|
||||
{
|
||||
secondTrans->setStatus(INVALID, secondLedgerSeq);
|
||||
ret=false;
|
||||
return false;
|
||||
}
|
||||
else secondTrans->setStatus(INCLUDED, secondLedgerSeq);
|
||||
}
|
||||
assert(firstTrans || secondTrans);
|
||||
if(firstTrans && secondTrans && (firstTrans->getStatus()!=INVALID) && (secondTrans->getStatus()!=INVALID))
|
||||
ret=false; // one or the other SHAMap is structurally invalid or a miracle has happened
|
||||
return false; // one or the other SHAMap is structurally invalid or a miracle has happened
|
||||
|
||||
outMap[id]=std::pair<Transaction::pointer, Transaction::pointer>(firstTrans, secondTrans);
|
||||
}
|
||||
return ret;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool isHex(char j)
|
||||
|
||||
Reference in New Issue
Block a user