diff --git a/src/LedgerProposal.cpp b/src/LedgerProposal.cpp index 94cd3d4e28..b386e599c1 100644 --- a/src/LedgerProposal.cpp +++ b/src/LedgerProposal.cpp @@ -6,12 +6,10 @@ #include "key.h" #include "Application.h" -LedgerProposal::LedgerProposal(const uint256& pLgr, uint32 seq, const uint256& tx, const std::string& pubKey) : +LedgerProposal::LedgerProposal(const uint256& pLgr, uint32 seq, const uint256& tx, const NewcoinAddress& naPeerPublic) : mPreviousLedger(pLgr), mCurrentHash(tx), mProposeSeq(seq) { - // XXX Make caller give us a vuc for pubkey. - - mPublicKey.setNodePublic(strCopy(pubKey)); + mPublicKey = naPeerPublic; // XXX Validate key. // if (!mKey->SetPubKey(pubKey)) // throw std::runtime_error("Invalid public key in proposal"); diff --git a/src/LedgerProposal.h b/src/LedgerProposal.h index 50a5e40123..52ab4091e9 100644 --- a/src/LedgerProposal.h +++ b/src/LedgerProposal.h @@ -27,7 +27,7 @@ public: typedef boost::shared_ptr pointer; // proposal from peer - LedgerProposal(const uint256& prevLgr, uint32 proposeSeq, const uint256& propose, const std::string& pubKey); + LedgerProposal(const uint256& prevLgr, uint32 proposeSeq, const uint256& propose, const NewcoinAddress& naPeerPublic); // our first proposal LedgerProposal(const NewcoinAddress& naSeed, const uint256& prevLedger, const uint256& position); diff --git a/src/NetworkOPs.cpp b/src/NetworkOPs.cpp index db14bbf94c..1492f69c70 100644 --- a/src/NetworkOPs.cpp +++ b/src/NetworkOPs.cpp @@ -456,9 +456,14 @@ int NetworkOPs::beginConsensus(Ledger::pointer closingLedger) return mConsensus->startup(); } +// <-- bool: true to relay bool NetworkOPs::recvPropose(uint32 proposeSeq, const uint256& proposeHash, const std::string& pubKey, const std::string& signature) { + // XXX Validate key. + // XXX Take a vuc for pubkey. + NewcoinAddress naPeerPublic = NewcoinAddress::createNodePublic(strCopy(pubKey)); + if (mMode != omFULL) // FIXME: Should we relay? { Log(lsWARNING) << "Received proposal when not full: " << mMode; @@ -474,7 +479,7 @@ bool NetworkOPs::recvPropose(uint32 proposeSeq, const uint256& proposeHash, if (!consensus) return false; LedgerProposal::pointer proposal = - boost::make_shared(consensus->getLCL(), proposeSeq, proposeHash, pubKey); + boost::make_shared(consensus->getLCL(), proposeSeq, proposeHash, naPeerPublic); if (!proposal->checkSign(signature)) { // Note that if the LCL is different, the signature check will fail Log(lsWARNING) << "Ledger proposal fails signature check"; @@ -482,7 +487,9 @@ bool NetworkOPs::recvPropose(uint32 proposeSeq, const uint256& proposeHash, } // Is this node on our UNL? - // WRITEME + // XXX Is this right? + if (!theApp->getUNL().nodeInUNL(naPeerPublic)) + return true; return consensus->peerPosition(proposal); }