mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Cut to 32-bit network times.
This commit is contained in:
@@ -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<unsigned char> getPubKey() const { return mPublicKey.getNodePublic(); }
|
||||
std::vector<unsigned char> sign();
|
||||
|
||||
void changePosition(const uint256& newPosition, uint64 newCloseTime);
|
||||
void changePosition(const uint256& newPosition, uint32 newCloseTime);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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<unsigned char>& myNode, std::list< std::vector<unsigned char> >& 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> peer, const uint256& hash,
|
||||
const std::list<SHAMapNode>& nodeIDs, const std::list< std::vector<unsigned char> >& nodeData);
|
||||
|
||||
@@ -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)))
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<uint256, ValidationSet>::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<uint256, int> ValidationCollection::getCurrentValidations()
|
||||
{
|
||||
uint64 now = theApp->getOPs().getNetworkTimeNC();
|
||||
uint32 now = theApp->getOPs().getNetworkTimeNC();
|
||||
boost::unordered_map<uint256, int> ret;
|
||||
|
||||
{
|
||||
|
||||
@@ -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<uint256, int> getCurrentValidations();
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user