diff --git a/src/LedgerProposal.h b/src/LedgerProposal.h index 79f3a67b6..1490e9d5e 100644 --- a/src/LedgerProposal.h +++ b/src/LedgerProposal.h @@ -13,8 +13,7 @@ class LedgerProposal protected: uint256 mPreviousLedger, mCurrentHash; - uint64 mCloseTime; - uint32 mProposeSeq; + uint32 mCloseTime, mProposeSeq; uint160 mPeerID; NewcoinAddress mPublicKey; @@ -26,14 +25,14 @@ public: // proposal from peer LedgerProposal(const uint256& prevLgr, uint32 proposeSeq, const uint256& propose, - uint64 closeTime, const NewcoinAddress& naPeerPublic); + uint32 closeTime, const NewcoinAddress& naPeerPublic); // our first proposal LedgerProposal(const NewcoinAddress& privKey, const uint256& prevLedger, const uint256& position, - uint64 closeTime); + uint32 closeTime); // an unsigned "dummy" proposal for nodes not validating - LedgerProposal(const uint256& prevLedger, const uint256& position, uint64 closeTime); + LedgerProposal(const uint256& prevLedger, const uint256& position, uint32 closeTime); uint256 getSigningHash() const; bool checkSign(const std::string& signature, const uint256& signingHash); @@ -43,12 +42,12 @@ public: const uint256& getCurrentHash() const { return mCurrentHash; } const uint256& getPrevLedger() const { return mPreviousLedger; } uint32 getProposeSeq() const { return mProposeSeq; } - uint64 getCloseTime() const { return mCloseTime; } + uint32 getCloseTime() const { return mCloseTime; } const NewcoinAddress& peekPublic() const { return mPublicKey; } std::vector getPubKey() const { return mPublicKey.getNodePublic(); } std::vector sign(); - void changePosition(const uint256& newPosition, uint64 newCloseTime); + void changePosition(const uint256& newPosition, uint32 newCloseTime); }; #endif diff --git a/src/NetworkOPs.h b/src/NetworkOPs.h index 55f030a9a..f2950f673 100644 --- a/src/NetworkOPs.h +++ b/src/NetworkOPs.h @@ -79,7 +79,7 @@ public: NetworkOPs(boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster); // network information - uint64 getNetworkTimeNC(); + uint32 getNetworkTimeNC(); boost::posix_time::ptime getNetworkTimePT(); uint32 getCurrentLedgerID(); OperatingMode getOperatingMode() { return mMode; } @@ -151,7 +151,7 @@ public: const std::vector& myNode, std::list< std::vector >& newNodes); // ledger proposal/close functions - bool recvPropose(uint32 proposeSeq, const uint256& proposeHash, uint64 closeTime, + bool recvPropose(uint32 proposeSeq, const uint256& proposeHash, uint32 closeTime, const std::string& pubKey, const std::string& signature); bool gotTXData(boost::shared_ptr peer, const uint256& hash, const std::list& nodeIDs, const std::list< std::vector >& nodeData); diff --git a/src/Peer.cpp b/src/Peer.cpp index f39940211..6ac18e879 100644 --- a/src/Peer.cpp +++ b/src/Peer.cpp @@ -571,8 +571,8 @@ void Peer::recvHello(newcoin::TMHello& packet) // Cancel verification timeout. (void) mVerifyTimer.cancel(); - uint64 minTime = theApp->getOPs().getNetworkTimeNC() - 4; - uint64 maxTime = minTime + 8; + uint32 minTime = theApp->getOPs().getNetworkTimeNC() - 4; + uint32 maxTime = minTime + 8; if (packet.has_nettime() && ((packet.nettime() < minTime) || (packet.nettime() > maxTime))) { diff --git a/src/SerializedValidation.cpp b/src/SerializedValidation.cpp index adb570c86..f3b6799d6 100644 --- a/src/SerializedValidation.cpp +++ b/src/SerializedValidation.cpp @@ -6,7 +6,7 @@ SOElement SerializedValidation::sValidationFormat[] = { { sfFlags, "Flags", STI_UINT32, SOE_FLAGS, 0 }, { sfLedgerHash, "LedgerHash", STI_HASH256, SOE_REQUIRED, 0 }, - { sfCloseTime, "CloseTime", STI_UINT64, SOE_REQUIRED, 0 }, + { sfCloseTime, "CloseTime", STI_UINT32, SOE_REQUIRED, 0 }, { sfSigningKey, "SigningKey", STI_VL, SOE_REQUIRED, 0 }, { sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 }, }; @@ -19,12 +19,12 @@ SerializedValidation::SerializedValidation(SerializerIterator& sit, bool checkSi if (checkSignature && !isValid()) throw std::runtime_error("Invalid validation"); } -SerializedValidation::SerializedValidation(const uint256& ledgerHash, uint64 closeTime, +SerializedValidation::SerializedValidation(const uint256& ledgerHash, uint32 closeTime, const NewcoinAddress& naSeed, bool isFull) : STObject(sValidationFormat), mSignature("Signature"), mTrusted(false) { setValueFieldH256(sfLedgerHash, ledgerHash); - setValueFieldU64(sfCloseTime, closeTime); + setValueFieldU32(sfCloseTime, closeTime); if (naSeed.isValid()) setValueFieldVL(sfSigningKey, NewcoinAddress::createNodePublic(naSeed).getNodePublic()); if (!isFull) setFlag(sFullFlag); @@ -50,9 +50,9 @@ uint256 SerializedValidation::getLedgerHash() const return getValueFieldH256(sfLedgerHash); } -uint64 SerializedValidation::getCloseTime() const +uint32 SerializedValidation::getCloseTime() const { - return getValueFieldU64(sfCloseTime); + return getValueFieldU32(sfCloseTime); } bool SerializedValidation::isValid() const diff --git a/src/SerializedValidation.h b/src/SerializedValidation.h index 85cfa0d84..dc5b7bbf0 100644 --- a/src/SerializedValidation.h +++ b/src/SerializedValidation.h @@ -22,10 +22,10 @@ public: SerializedValidation(SerializerIterator& sit, bool checkSignature = true); SerializedValidation(const Serializer& s, bool checkSignature = true); - SerializedValidation(const uint256& ledgerHash, uint64 closeTime, const NewcoinAddress& naSeed, bool isFull); + SerializedValidation(const uint256& ledgerHash, uint32 closeTime, const NewcoinAddress& naSeed, bool isFull); uint256 getLedgerHash() const; - uint64 getCloseTime() const; + uint32 getCloseTime() const; NewcoinAddress getSignerPublic() const; bool isValid() const; bool isFull() const; diff --git a/src/Serializer.h b/src/Serializer.h index ab39a1c30..5c687e298 100644 --- a/src/Serializer.h +++ b/src/Serializer.h @@ -32,8 +32,8 @@ public: // assemble functions int add8(unsigned char byte); int add16(uint16); - int add32(uint32); // ledger indexes, account sequence - int add64(uint64); // timestamps, amounts + int add32(uint32); // ledger indexes, account sequence, timestamps + int add64(uint64); // native currency amounts int add128(const uint128&); // private key generators int add160(const uint160&); // account names, hankos int add256(const uint256&); // transaction and ledger hashes diff --git a/src/ValidationCollection.cpp b/src/ValidationCollection.cpp index 4701e9bc5..e031865dc 100644 --- a/src/ValidationCollection.cpp +++ b/src/ValidationCollection.cpp @@ -11,8 +11,8 @@ bool ValidationCollection::addValidation(SerializedValidation::pointer val) if (theApp->getUNL().nodeInUNL(val->getSignerPublic())) { val->setTrusted(); - uint64 now = theApp->getOPs().getNetworkTimeNC(); - uint64 valClose = val->getCloseTime(); + uint32 now = theApp->getOPs().getNetworkTimeNC(); + uint32 valClose = val->getCloseTime(); if ((now > valClose) && (now < (valClose + LEDGER_MAX_INTERVAL))) isCurrent = true; else @@ -55,7 +55,7 @@ void ValidationCollection::getValidationCount(const uint256& ledger, bool curren trusted = untrusted = 0; boost::mutex::scoped_lock sl(mValidationLock); boost::unordered_map::iterator it = mValidations.find(ledger); - uint64 now = theApp->getOPs().getNetworkTimeNC(); + uint32 now = theApp->getOPs().getNetworkTimeNC(); if (it != mValidations.end()) { for (ValidationSet::iterator vit = it->second.begin(), end = it->second.end(); vit != end; ++vit) @@ -63,7 +63,7 @@ void ValidationCollection::getValidationCount(const uint256& ledger, bool curren bool trusted = vit->second->isTrusted(); if (trusted && currentOnly) { - uint64 closeTime = vit->second->getCloseTime(); + uint32 closeTime = vit->second->getCloseTime(); if ((now < closeTime) || (now > (closeTime + 2 * LEDGER_MAX_INTERVAL))) trusted = false; } @@ -91,7 +91,7 @@ int ValidationCollection::getTrustedValidationCount(const uint256& ledger) return trusted; } -int ValidationCollection::getCurrentValidationCount(uint64 afterTime) +int ValidationCollection::getCurrentValidationCount(uint32 afterTime) { int count = 0; boost::mutex::scoped_lock sl(mValidationLock); @@ -106,7 +106,7 @@ int ValidationCollection::getCurrentValidationCount(uint64 afterTime) boost::unordered_map ValidationCollection::getCurrentValidations() { - uint64 now = theApp->getOPs().getNetworkTimeNC(); + uint32 now = theApp->getOPs().getNetworkTimeNC(); boost::unordered_map ret; { diff --git a/src/ValidationCollection.h b/src/ValidationCollection.h index c4c82e9d5..5c6feacfe 100644 --- a/src/ValidationCollection.h +++ b/src/ValidationCollection.h @@ -25,7 +25,7 @@ public: ValidationSet getValidations(const uint256& ledger); void getValidationCount(const uint256& ledger, bool currentOnly, int& trusted, int& untrusted); int getTrustedValidationCount(const uint256& ledger); - int getCurrentValidationCount(uint64 afterTime); + int getCurrentValidationCount(uint32 afterTime); boost::unordered_map getCurrentValidations(); }; diff --git a/src/newcoin.proto b/src/newcoin.proto index af81caeaf..79f517468 100644 --- a/src/newcoin.proto +++ b/src/newcoin.proto @@ -105,7 +105,7 @@ message TMProposeSet { required uint32 proposeSeq = 1; required bytes currentTxHash = 2; // the hash of the ledger we are proposing required bytes nodePubKey = 3; - required uint64 closeTime = 4; + required uint32 closeTime = 4; required bytes signature = 5; // signature of above fields repeated bytes addedTransactions = 6; // not required if number is large repeated bytes removedTransactions = 7; // not required if number is large