Split and refactor ProofOfWork

This commit is contained in:
Vinnie Falco
2013-06-05 07:09:00 -07:00
parent 4d1bf35236
commit 38edcc8f0d
19 changed files with 356 additions and 305 deletions

View File

@@ -20,7 +20,6 @@
#include "NicknameState.h"
#include "Offer.h"
#include "PFRequest.h"
#include "ProofOfWork.h"
SETUP_LOG (RPCHandler)
@@ -889,7 +888,7 @@ Json::Value RPCHandler::doProofCreate(Json::Value jvRequest, int& cost, ScopedLo
if (jvRequest.isMember("difficulty") || jvRequest.isMember("secret"))
{
ProofOfWorkGenerator pgGen;
ProofOfWorkFactory pgGen;
if (jvRequest.isMember("difficulty"))
{
@@ -913,7 +912,7 @@ Json::Value RPCHandler::doProofCreate(Json::Value jvRequest, int& cost, ScopedLo
jvResult["token"] = pgGen.getProof().getToken();
jvResult["secret"] = pgGen.getSecret().GetHex();
} else {
jvResult["token"] = theApp->getPowGen().getProof().getToken();
jvResult["token"] = theApp->getProofOfWorkFactory().getProof().getToken();
}
return jvResult;
@@ -971,7 +970,7 @@ Json::Value RPCHandler::doProofVerify(Json::Value jvRequest, int& cost, ScopedLo
POWResult prResult;
if (jvRequest.isMember("difficulty") || jvRequest.isMember("secret"))
{
ProofOfWorkGenerator pgGen;
ProofOfWorkFactory pgGen;
if (jvRequest.isMember("difficulty"))
{
@@ -999,7 +998,7 @@ Json::Value RPCHandler::doProofVerify(Json::Value jvRequest, int& cost, ScopedLo
else
{
// XXX Proof should not be marked as used from this
prResult = theApp->getPowGen().checkProof(strToken, uSolution);
prResult = theApp->getProofOfWorkFactory().checkProof(strToken, uSolution);
}
std::string sToken;