Merge branch 'master' of github.com:jedmccaleb/NewCoin

This commit is contained in:
Arthur Britto
2012-10-10 12:44:11 -07:00
6 changed files with 28 additions and 13 deletions

View File

@@ -98,12 +98,14 @@ void Application::run()
Log(lsINFO) << "Loading Old Ledger";
loadOldLedger();
}
else
{ // TODO: This should really not validate a ledger until it gets the current one from our peers
// but I'll let david make this change since a lot of code assumes we have a ledger
// for now just do what we always were doing
else if (theConfig.START_UP == Config::NETWORK)
{ // This should probably become the default once we have a stable network
if (!theConfig.RUN_STANDALONE)
mNetOps.needNetworkLedger();
startNewLedger();
}
else
startNewLedger();
//
// Begin validation and ip maintenance.

View File

@@ -56,7 +56,7 @@ public:
std::vector<std::string> IPS; // Peer IPs from newcoind.cfg.
std::vector<std::string> SNTP_SERVERS; // SNTP servers from newcoind.cfg.
enum StartUpType {FRESH,NORMAL,LOAD};
enum StartUpType { FRESH, NORMAL, LOAD, NETWORK };
StartUpType START_UP;
// Network parameters

View File

@@ -26,8 +26,9 @@
SETUP_LOG();
NetworkOPs::NetworkOPs(boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster) :
mMode(omDISCONNECTED),mNetTimer(io_service), mLedgerMaster(pLedgerMaster), mCloseTimeOffset(0),
mLastCloseProposers(0), mLastCloseConvergeTime(1000 * LEDGER_IDLE_INTERVAL), mLastValidationTime(0)
mMode(omDISCONNECTED), mNeedNetworkLedger(false), mNetTimer(io_service), mLedgerMaster(pLedgerMaster),
mCloseTimeOffset(0), mLastCloseProposers(0), mLastCloseConvergeTime(1000 * LEDGER_IDLE_INTERVAL),
mLastValidationTime(0)
{
}
@@ -424,7 +425,8 @@ void NetworkOPs::checkState(const boost::system::error_code& result)
// If full or tracking, check only at wobble time!
uint256 networkClosed;
bool ledgerChange = checkLastClosedLedger(peerList, networkClosed);
if(networkClosed.isZero())return;
if(networkClosed.isZero())
return;
// WRITEME: Unless we are in omFULL and in the process of doing a consensus,
// we must count how many nodes share our LCL, how many nodes disagree with our LCL,
@@ -435,7 +437,8 @@ void NetworkOPs::checkState(const boost::system::error_code& result)
if ((mMode == omCONNECTED) && !ledgerChange)
{ // count number of peers that agree with us and UNL nodes whose validations we have for LCL
// if the ledger is good enough, go to omTRACKING - TODO
setMode(omTRACKING);
if (!mNeedNetworkLedger)
setMode(omTRACKING);
}
if ((mMode == omTRACKING) && !ledgerChange )
@@ -617,6 +620,7 @@ void NetworkOPs::switchLastClosedLedger(Ledger::pointer newLedger, bool duringCo
else
cLog(lsERROR) << "JUMP last closed ledger to " << newLedger->getHash();
mNeedNetworkLedger = false;
newLedger->setClosed();
Ledger::pointer openLedger = boost::make_shared<Ledger>(false, boost::ref(*newLedger));
mLedgerMaster->switchLedgers(newLedger, openLedger);

View File

@@ -52,6 +52,7 @@ protected:
typedef boost::unordered_map<uint160,boost::unordered_set<InfoSub*> >::iterator subInfoMapIterator;
OperatingMode mMode;
bool mNeedNetworkLedger;
boost::posix_time::ptime mConnectTime;
boost::asio::deadline_timer mNetTimer;
boost::shared_ptr<LedgerConsensus> mConsensus;
@@ -184,6 +185,7 @@ public:
void setStandAlone() { setMode(omFULL); }
void setStateTimer();
void newLCL(int proposers, int convergeTime, const uint256& ledgerHash);
void needNetworkLedger() { mNeedNetworkLedger = true; }
void consensusViewChange();
int getPreviousProposers() { return mLastCloseProposers; }
int getPreviousConvergeTime() { return mLastCloseConvergeTime; }

View File

@@ -24,6 +24,7 @@
// 8-bit integers
FIELD(CloseResolution, UINT8, 1)
FIELD(TemplateEntryType, UINT8, 2)
// 16-bit integers
FIELD(LedgerEntryType, UINT16, 1)
@@ -123,9 +124,13 @@
// inner object
// OBJECT/1 is reserved for end of object
FIELD(TemplateEntry, OBJECT, 1)
// array of objects
// ARRAY/1 is reserved for end of array
FIELD(SigningAccounts, ARRAY, 2)
FIELD(TxnSignatures, ARRAY, 3)
FIELD(Signatures, ARRAY, 4)
FIELD(Template, ARRAY, 5)
FIELD(Necessary, ARRAY, 6)
FIELD(Sufficient, ARRAY, 7)

View File

@@ -98,8 +98,9 @@ int main(int argc, char* argv[])
("test,t", "Perform unit tests.")
("parameters", po::value< vector<string> >(), "Specify comma separated parameters.")
("verbose,v", "Increase log level.")
("load","Load the current ledger from the local DB.")
("start","Start from a fresh Ledger.")
("load", "Load the current ledger from the local DB.")
("start", "Start from a fresh Ledger.")
("net", "Get the initial ledger from the network.")
;
// Interpret positional arguments as --parameters.
@@ -156,8 +157,9 @@ int main(int argc, char* argv[])
}
}
if(vm.count("start")) theConfig.START_UP=Config::FRESH;
else if(vm.count("load")) theConfig.START_UP=Config::LOAD;
if (vm.count("start")) theConfig.START_UP = Config::FRESH;
else if (vm.count("load")) theConfig.START_UP = Config::LOAD;
else if (vm.count("net")) theConfig.START_UP = Config::NETWORK;
if (iResult)
{