Check UNL before processing validation.

This commit is contained in:
Arthur Britto
2012-06-13 16:53:09 -07:00
parent bec2891800
commit ab9cc7f70c
3 changed files with 12 additions and 7 deletions

View File

@@ -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");

View File

@@ -27,7 +27,7 @@ public:
typedef boost::shared_ptr<LedgerProposal> 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);

View File

@@ -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<LedgerProposal>(consensus->getLCL(), proposeSeq, proposeHash, pubKey);
boost::make_shared<LedgerProposal>(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);
}