diff --git a/src/LedgerConsensus.cpp b/src/LedgerConsensus.cpp index 2aacf34c47..c98ce7c1b7 100644 --- a/src/LedgerConsensus.cpp +++ b/src/LedgerConsensus.cpp @@ -845,17 +845,15 @@ void LedgerConsensus::Saccept(boost::shared_ptr This, SHAMap::p void LedgerConsensus::deferProposal(const LedgerProposal::pointer& proposal, const NewcoinAddress& peerPublic) { - if (!peerPublic.isValid()) - return; std::list& props = mDeferredProposals[peerPublic.getNodeID()]; - if (props.size() > (mPreviousProposers + 10)) + if (props.size() >= (mPreviousProposers + 10)) props.pop_front(); props.push_back(proposal); } void LedgerConsensus::playbackProposals() { - for ( boost::unordered_map< uint160, std::list >::iterator + for (boost::unordered_map< uint160, std::list >::iterator it = mDeferredProposals.begin(), end = mDeferredProposals.end(); it != end; ++it) { BOOST_FOREACH(const LedgerProposal::pointer& proposal, it->second) diff --git a/src/NetworkOPs.cpp b/src/NetworkOPs.cpp index 71737638c0..4fba90529e 100644 --- a/src/NetworkOPs.cpp +++ b/src/NetworkOPs.cpp @@ -616,7 +616,7 @@ bool NetworkOPs::recvPropose(uint32 proposeSeq, const uint256& proposeHash, uint if (!theApp->isNew(s.getSHA512Half())) return false; - NewcoinAddress naPeerPublic = NewcoinAddress::createNodePublic(strCopy(pubKey)); + NewcoinAddress naPeerPublic = NewcoinAddress::createNodePublic(pubKey); if ((!mConsensus) && (mMode == omFULL)) { @@ -632,7 +632,14 @@ bool NetworkOPs::recvPropose(uint32 proposeSeq, const uint256& proposeHash, uint if (!mConsensus) { Log(lsINFO) << "Received proposal outside consensus window"; - return (mMode != omFULL); + return mMode != omFULL; + } + + // Is this node on our UNL? + if (!theApp->getUNL().nodeInUNL(naPeerPublic)) + { + Log(lsINFO) << "Untrusted proposal: " << naPeerPublic.humanNodePublic() << " " << proposeHash.GetHex(); + return true; } LedgerProposal::pointer proposal = @@ -640,22 +647,11 @@ bool NetworkOPs::recvPropose(uint32 proposeSeq, const uint256& proposeHash, uint if (!proposal->checkSign(signature)) { // Note that if the LCL is different, the signature check will fail Log(lsWARNING) << "Ledger proposal fails signature check"; - if ((mMode != omFULL) && (mMode != omTRACKING) && theApp->getUNL().nodeInUNL(proposal->peekPublic())) - { - proposal->setSignature(signature); - mConsensus->deferProposal(proposal, nodePublic); - } + proposal->setSignature(signature); + mConsensus->deferProposal(proposal, nodePublic); return false; } - // Is this node on our UNL? - if (!theApp->getUNL().nodeInUNL(proposal->peekPublic())) - { - Log(lsINFO) << "Untrusted proposal: " << naPeerPublic.humanNodePublic() << " " << - proposal->getCurrentHash().GetHex(); - return true; - } - return mConsensus->peerPosition(proposal); } diff --git a/src/NewcoinAddress.cpp b/src/NewcoinAddress.cpp index 29b87fe378..be7583dcd7 100644 --- a/src/NewcoinAddress.cpp +++ b/src/NewcoinAddress.cpp @@ -95,6 +95,15 @@ NewcoinAddress NewcoinAddress::createNodePublic(const std::vector return naNew; } +NewcoinAddress NewcoinAddress::createNodePublic(const std::string& strPublic) +{ + NewcoinAddress naNew; + + naNew.setNodePublic(strPublic); + + return naNew; +} + uint160 NewcoinAddress::getNodeID() const { switch (nVersion) { diff --git a/src/NewcoinAddress.h b/src/NewcoinAddress.h index c591d1b0d7..369b609d04 100644 --- a/src/NewcoinAddress.h +++ b/src/NewcoinAddress.h @@ -46,6 +46,7 @@ public: static NewcoinAddress createNodePublic(const NewcoinAddress& naSeed); static NewcoinAddress createNodePublic(const std::vector& vPublic); + static NewcoinAddress createNodePublic(const std::string& strPublic); // // Node Private diff --git a/src/Peer.cpp b/src/Peer.cpp index 40b243f865..83a4272f76 100644 --- a/src/Peer.cpp +++ b/src/Peer.cpp @@ -721,11 +721,10 @@ void Peer::recvPropose(newcoin::TMProposeSet& packet) return; } - uint32 proposeSeq = packet.proposeseq(); uint256 currentTxHash; memcpy(currentTxHash.begin(), packet.currenttxhash().data(), 32); - if(theApp->getOPs().recvPropose(proposeSeq, currentTxHash, packet.closetime(), + if(theApp->getOPs().recvPropose(packet.proposeseq(), currentTxHash, packet.closetime(), packet.nodepubkey(), packet.signature(), mNodePublic)) { // FIXME: Not all nodes will want proposals PackedMessage::pointer message = boost::make_shared(packet, newcoin::mtPROPOSE_LEDGER);