Slots the PoW peer code will go into.

This commit is contained in:
JoelKatz
2012-11-25 21:32:21 -08:00
parent ca59a885ca
commit ea94feb643
4 changed files with 50 additions and 20 deletions

View File

@@ -23,22 +23,23 @@ enum JobType
jtINVALID = -1,
jtVALIDATION_ut = 0, // A validation from an untrusted source
jtCLIENTOP_ut = 1, // A client operation from a non-local/untrusted source
jtTRANSACTION = 2, // A transaction received from the network
jtPROPOSAL_ut = 3, // A proposal from an untrusted source
jtCLIENTOP_t = 4, // A client operation from a trusted source
jtVALIDATION_t = 5, // A validation from a trusted source
jtTRANSACTION_l = 6, // A local transaction
jtPROPOSAL_t = 7, // A proposal from a trusted source
jtADMIN = 8, // An administrative operation
jtDEATH = 9, // job of death, used internally
jtPROOFWORK = 2, // A proof of work demand from another server
jtTRANSACTION = 3, // A transaction received from the network
jtPROPOSAL_ut = 4, // A proposal from an untrusted source
jtCLIENTOP_t = 5, // A client operation from a trusted source
jtVALIDATION_t = 6, // A validation from a trusted source
jtTRANSACTION_l = 7, // A local transaction
jtPROPOSAL_t = 8, // A proposal from a trusted source
jtADMIN = 9, // An administrative operation
jtDEATH = 10, // job of death, used internally
// special types not dispatched by the job pool
jtCLIENT = 10,
jtPEER = 11,
jtDISK = 12,
jtRPC = 13,
jtACCEPTLEDGER = 14,
jtPUBLEDGER = 15,
jtCLIENT = 16,
jtPEER = 17,
jtDISK = 18,
jtRPC = 19,
jtACCEPTLEDGER = 20,
jtPUBLEDGER = 21,
};
#define NUM_JOB_TYPES 24

View File

@@ -581,6 +581,17 @@ void Peer::processReadBuffer()
}
break;
case ripple::mtPROOFOFWORK:
{
ripple::TMProofWork msg;
if (msg.ParseFromArray(&mReadbuf[HEADER_SIZE], mReadbuf.size() - HEADER_SIZE))
recvProofWork(msg);
else
cLog(lsWARNING) << "parse error: " << type;
}
break;
default:
cLog(lsWARNING) << "Unknown Msg: " << type;
cLog(lsWARNING) << strHex(&mReadbuf[0], mReadbuf.size());
@@ -1124,6 +1135,23 @@ void Peer::recvAccount(ripple::TMAccount& packet)
{
}
void Peer::recvProofWork(ripple::TMProofWork& packet)
{
if (packet.has_result())
{ // this is a reply to a proof of work we sent
// WRITEME
return;
}
if (packet.has_target() && packet.has_challenge() && packet.has_iterations())
{ // this is a challenge
// WRITEME
return;
}
cLog(lsINFO) << "Received in valid proof of work object from peer";
}
void Peer::recvStatus(ripple::TMStatusChange& packet)
{
cLog(lsTRACE) << "Received status change from peer " << getIP();

View File

@@ -126,6 +126,7 @@ protected:
void recvStatus(ripple::TMStatusChange& packet);
void recvPropose(const boost::shared_ptr<ripple::TMProposeSet>& packet);
void recvHaveTxSet(ripple::TMHaveTransactionSet& packet);
void recvProofWork(ripple::TMProofWork& packet);
void getSessionCookie(std::string& strDst);

View File

@@ -5,7 +5,7 @@ enum MessageType {
mtHELLO = 1;
mtERROR_MSG = 2;
mtPING = 3;
mtPOW = 4;
mtPROOFOFWORK = 4;
// network presence detection
mtGET_CONTACTS = 10;
@@ -33,13 +33,13 @@ enum MessageType {
}
// empty message (or just result) = request proof of work
// token, iterations, target, challenge = give proof of work challenge
// token, response = show proof of work
// token, result = result of pow attempt
// token, iterations, target, challenge = issue demand for proof of work
// token, response = give solution to proof of work
// token, result = report result of pow
message TMProofWork
{
optional string token = 1;
required string token = 1;
optional uint32 iterations = 2;
optional bytes target = 3;
optional bytes challenge = 4;