mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Code to determine how old a proposal is.
Low-level code to remove a peer from the consensus process.
This commit is contained in:
@@ -161,6 +161,18 @@ void LCTransaction::setVote(const uint160& peer, bool votesYes)
|
||||
}
|
||||
}
|
||||
|
||||
void LCTransaction::unVote(const uint160& peer)
|
||||
{
|
||||
boost::unordered_map<uint160, bool>::iterator it = mVotes.find(peer);
|
||||
if (it != mVotes.end())
|
||||
{
|
||||
if (it->second)
|
||||
--mYays;
|
||||
else
|
||||
--mNays;
|
||||
}
|
||||
}
|
||||
|
||||
bool LCTransaction::updatePosition(int percentTime, bool proposing)
|
||||
{ // this many seconds after close, should our position change
|
||||
if (mOurPosition && (mNays == 0))
|
||||
@@ -766,6 +778,13 @@ bool LedgerConsensus::peerPosition(const LedgerProposal::pointer& newPosition)
|
||||
return true;
|
||||
}
|
||||
|
||||
void LedgerConsensus::removePeer(const uint160& peerID)
|
||||
{
|
||||
mPeerPositions.erase(peerID);
|
||||
BOOST_FOREACH(u256_lct_pair& it, mDisputes)
|
||||
it.second->unVote(peerID);
|
||||
}
|
||||
|
||||
bool LedgerConsensus::peerHasSet(const Peer::pointer& peer, const uint256& hashSet, newcoin::TxSetStatus status)
|
||||
{
|
||||
if (status != newcoin::tsHAVE) // Indirect requests are for future support
|
||||
|
||||
@@ -64,6 +64,7 @@ public:
|
||||
Serializer& peekTransaction() { return transaction; }
|
||||
|
||||
void setVote(const uint160& peer, bool votesYes);
|
||||
void unVote(const uint160& peer);
|
||||
|
||||
bool updatePosition(int percentTime, bool proposing);
|
||||
};
|
||||
@@ -171,6 +172,7 @@ public:
|
||||
bool haveConsensus();
|
||||
|
||||
bool peerPosition(const LedgerProposal::pointer&);
|
||||
void removePeer(const uint160& peerID);
|
||||
void deferProposal(const LedgerProposal::pointer& proposal, const NewcoinAddress& peerPublic);
|
||||
|
||||
bool peerHasSet(const Peer::pointer& peer, const uint256& set, newcoin::TxSetStatus status);
|
||||
|
||||
@@ -9,14 +9,14 @@
|
||||
|
||||
LedgerProposal::LedgerProposal(const uint256& pLgr, uint32 seq, const uint256& tx, uint32 closeTime,
|
||||
const NewcoinAddress& naPeerPublic) :
|
||||
mPreviousLedger(pLgr), mCurrentHash(tx), mCloseTime(closeTime), mProposeSeq(seq)
|
||||
mPreviousLedger(pLgr), mCurrentHash(tx), mCloseTime(closeTime), mProposeSeq(seq), mPublicKey(naPeerPublic)
|
||||
{
|
||||
mPublicKey = naPeerPublic;
|
||||
// XXX Validate key.
|
||||
// if (!mKey->SetPubKey(pubKey))
|
||||
// throw std::runtime_error("Invalid public key in proposal");
|
||||
|
||||
mPeerID = mPublicKey.getNodeID();
|
||||
mTime = boost::posix_time::second_clock::universal_time();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +27,13 @@ LedgerProposal::LedgerProposal(const NewcoinAddress& naSeed, const uint256& prev
|
||||
mPublicKey = NewcoinAddress::createNodePublic(naSeed);
|
||||
mPrivateKey = NewcoinAddress::createNodePrivate(naSeed);
|
||||
mPeerID = mPublicKey.getNodeID();
|
||||
mTime = boost::posix_time::second_clock::universal_time();
|
||||
}
|
||||
|
||||
LedgerProposal::LedgerProposal(const uint256& prevLgr, const uint256& position, uint32 closeTime) :
|
||||
mPreviousLedger(prevLgr), mCurrentHash(position), mCloseTime(closeTime), mProposeSeq(0)
|
||||
{
|
||||
;
|
||||
mTime = boost::posix_time::second_clock::universal_time();
|
||||
}
|
||||
|
||||
uint256 LedgerProposal::getSigningHash() const
|
||||
|
||||
@@ -22,7 +22,8 @@ protected:
|
||||
NewcoinAddress mPublicKey;
|
||||
NewcoinAddress mPrivateKey; // If ours
|
||||
|
||||
std::string mSignature; // set only if needed
|
||||
std::string mSignature; // set only if needed
|
||||
boost::posix_time::ptime mTime;
|
||||
|
||||
public:
|
||||
|
||||
@@ -55,7 +56,7 @@ public:
|
||||
|
||||
void setPrevLedger(const uint256& prevLedger) { mPreviousLedger = prevLedger; }
|
||||
void setSignature(const std::string& signature) { mSignature = signature; }
|
||||
|
||||
const boost::posix_time::ptime getCreateTime() { return mTime; }
|
||||
|
||||
void changePosition(const uint256& newPosition, uint32 newCloseTime);
|
||||
Json::Value getJson() const;
|
||||
|
||||
Reference in New Issue
Block a user