mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Dispatch on consensus.
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
#include "LedgerConsensus.h"
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "Application.h"
|
||||
#include "NetworkOPs.h"
|
||||
#include "LedgerTiming.h"
|
||||
@@ -521,16 +524,34 @@ bool LedgerConsensus::peerGaveNodes(Peer::pointer peer, const uint256& setHash,
|
||||
}
|
||||
|
||||
void LedgerConsensus::beginAccept()
|
||||
{
|
||||
SHAMap::pointer consensusSet = mComplete[mOurPosition->getCurrentHash()];
|
||||
if (!consensusSet)
|
||||
{
|
||||
std::cerr << "We don't have our own set" << std::endl;
|
||||
assert(false);
|
||||
abort();
|
||||
return;
|
||||
}
|
||||
|
||||
boost::thread thread(boost::bind(&LedgerConsensus::Saccept, shared_from_this(), consensusSet));
|
||||
thread.detach();
|
||||
}
|
||||
|
||||
void LedgerConsensus::Saccept(boost::shared_ptr<LedgerConsensus> This, SHAMap::pointer txSet)
|
||||
{
|
||||
This->accept(txSet);
|
||||
}
|
||||
|
||||
void LedgerConsensus::accept(SHAMap::pointer set)
|
||||
{
|
||||
// WRITEME
|
||||
// 1) Extract the consensus transaction set
|
||||
// 2) Snapshot the last closed ledger
|
||||
// 3) Dispatch a thread to:
|
||||
// A) apply the consensus transaction set in canonical order
|
||||
// B) Apply the consensus transaction set and replace the last closed ledger
|
||||
// C) Rebuild the current ledger, applying as many transactions as possible
|
||||
// D) Send a network state change
|
||||
// E) Change the consensus state to lcsACCEPTED
|
||||
// A) Snapshot the LCL
|
||||
// B) apply the consensus transaction set in canonical order
|
||||
// C) Apply the consensus transaction set and replace the last closed ledger
|
||||
// D) Rebuild the current ledger, applying as many transactions as possible
|
||||
// E) Send a network state change
|
||||
// F) Change the consensus state to lcsACCEPTED
|
||||
}
|
||||
|
||||
void LedgerConsensus::endConsensus()
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <list>
|
||||
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <boost/unordered/unordered_map.hpp>
|
||||
|
||||
#include "key.h"
|
||||
@@ -74,7 +75,7 @@ enum LCState
|
||||
lcsABORTED // Abandoned
|
||||
};
|
||||
|
||||
class LedgerConsensus
|
||||
class LedgerConsensus : public boost::enable_shared_from_this<LedgerConsensus>
|
||||
{
|
||||
protected:
|
||||
LCState mState;
|
||||
@@ -95,6 +96,10 @@ protected:
|
||||
// Disputed transactions
|
||||
boost::unordered_map<uint256, LCTransaction::pointer, hash_SMN> mDisputes;
|
||||
|
||||
// final accept logic
|
||||
static void Saccept(boost::shared_ptr<LedgerConsensus> This, SHAMap::pointer txSet);
|
||||
void accept(SHAMap::pointer txSet);
|
||||
|
||||
void weHave(const uint256& id, Peer::pointer avoidPeer);
|
||||
void startAcquiring(TransactionAcquire::pointer);
|
||||
SHAMap::pointer find(const uint256& hash);
|
||||
|
||||
Reference in New Issue
Block a user