mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Ledger consensus stuff.
This commit is contained in:
@@ -87,6 +87,28 @@ bool TransactionAcquire::takeNodes(const std::list<SHAMapNode>& nodeIDs,
|
||||
return true;
|
||||
}
|
||||
|
||||
LedgerConsensus::LedgerConsensus(Ledger::pointer previousLedger)
|
||||
: mState(lcsPRE_CLOSE), mPreviousLedger(previousLedger)
|
||||
{
|
||||
}
|
||||
|
||||
void LedgerConsensus::closeTime(Ledger::pointer& current)
|
||||
{
|
||||
if (mState != lcsPRE_CLOSE)
|
||||
{
|
||||
assert(false);
|
||||
return;
|
||||
}
|
||||
CKey::pointer nodePrivKey = boost::make_shared<CKey>();
|
||||
nodePrivKey->MakeNewKey(); // FIXME
|
||||
|
||||
current->updateHash();
|
||||
uint256 txSet = current->getTransHash();
|
||||
mOurPosition = boost::make_shared<LedgerProposal>(nodePrivKey, current->getParentHash(), txSet);
|
||||
mComplete[txSet] = current->peekTransactionMap()->snapShot();
|
||||
// WRITME: Broadcast an IHAVE for this set
|
||||
}
|
||||
|
||||
void LedgerConsensus::abort()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -64,13 +64,20 @@ public:
|
||||
bool updatePosition(int timePassed);
|
||||
};
|
||||
|
||||
enum LCState
|
||||
{
|
||||
lcsPRE_CLOSE, // We haven't closed our ledger yet, but others might have
|
||||
lcsESTABLISH, // Establishing consensus
|
||||
lcsCUTOFF, // Past the cutoff for consensus
|
||||
lcsFINSHED, // We have closed on a transaction set
|
||||
lcsACCEPTED, // We have accepted/validated a new last closed ledger
|
||||
};
|
||||
|
||||
class LedgerConsensus
|
||||
{
|
||||
protected:
|
||||
Ledger::pointer mPreviousLedger, mCurrentLedger;
|
||||
LedgerProposal::pointer mCurrentProposal;
|
||||
|
||||
LCState mState;
|
||||
Ledger::pointer mPreviousLedger;
|
||||
LedgerProposal::pointer mOurPosition;
|
||||
|
||||
// Convergence tracking, trusted peers indexed by hash of public key
|
||||
@@ -91,13 +98,12 @@ protected:
|
||||
void removePosition(LedgerProposal&);
|
||||
|
||||
public:
|
||||
LedgerConsensus(Ledger::pointer previousLedger, Ledger::pointer currentLedger) :
|
||||
mPreviousLedger(previousLedger), mCurrentLedger(currentLedger) { ; }
|
||||
LedgerConsensus(Ledger::pointer previousLedger);
|
||||
void closeTime(Ledger::pointer& currentLedger);
|
||||
|
||||
int startup();
|
||||
|
||||
Ledger::pointer peekPreviousLedger() { return mPreviousLedger; }
|
||||
Ledger::pointer peekCurrentLedger() { return mCurrentLedger; }
|
||||
|
||||
SHAMap::pointer getTransactionTree(const uint256& hash, bool doAcquire);
|
||||
TransactionAcquire::pointer getAcquiring(const uint256& hash);
|
||||
|
||||
@@ -368,7 +368,8 @@ int NetworkOPs::beginConsensus(Ledger::pointer closingLedger)
|
||||
|
||||
// Create a consensus object to get consensus on this ledger
|
||||
if (!!mConsensus) mConsensus->abort();
|
||||
mConsensus = boost::make_shared<LedgerConsensus>(prevLedger, closingLedger);
|
||||
mConsensus = boost::make_shared<LedgerConsensus>(prevLedger);
|
||||
mConsensus->closeTime(closingLedger); // FIXME: Create consensus a few seconds before close time
|
||||
|
||||
#ifdef DEBUG
|
||||
std::cerr << "Broadcasting ledger close" << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user