diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj
index e082dba07f..76df0dc906 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj
+++ b/Builds/VisualStudio2013/RippleD.vcxproj
@@ -1845,18 +1845,6 @@
-
-
-
- True
-
-
-
-
- True
-
-
-
@@ -2916,15 +2904,6 @@
True
-
- True
-
-
- True
-
-
- True
-
True
diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters
index 42aefb3fc4..c4a983b540 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj.filters
+++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters
@@ -2730,21 +2730,6 @@
ripple\app\misc
-
- ripple\app\misc
-
-
- ripple\app\misc
-
-
- ripple\app\misc
-
-
- ripple\app\misc
-
-
- ripple\app\misc
-
ripple\app\misc
@@ -4014,15 +3999,6 @@
ripple\rpc\handlers
-
- ripple\rpc\handlers
-
-
- ripple\rpc\handlers
-
-
- ripple\rpc\handlers
-
ripple\rpc\handlers
diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp
index 3ceeea62ce..38a5316384 100644
--- a/src/ripple/app/main/Application.cpp
+++ b/src/ripple/app/main/Application.cpp
@@ -19,7 +19,6 @@
#include
#include
-#include
#include
#include
#include
@@ -188,7 +187,6 @@ public:
std::unique_ptr mFeeTrack;
std::unique_ptr mHashRouter;
std::unique_ptr mValidations;
- std::unique_ptr mProofOfWorkFactory;
std::unique_ptr m_loadManager;
beast::DeadlineTimer m_sweepTimer;
@@ -330,8 +328,6 @@ public:
, mValidations (make_Validations ())
- , mProofOfWorkFactory (make_ProofOfWorkFactory ())
-
, m_loadManager (LoadManager::New (*this, m_logs.journal("LoadManager")))
, m_sweepTimer (this)
@@ -507,11 +503,6 @@ public:
return *m_deprecatedUNL;
}
- ProofOfWorkFactory& getProofOfWorkFactory ()
- {
- return *mProofOfWorkFactory;
- }
-
SHAMapStore& getSHAMapStore () override
{
return *m_shaMapStore;
diff --git a/src/ripple/app/main/Application.h b/src/ripple/app/main/Application.h
index e608f393ee..f6fc73275d 100644
--- a/src/ripple/app/main/Application.h
+++ b/src/ripple/app/main/Application.h
@@ -52,7 +52,6 @@ class NetworkOPs;
class OrderBookDB;
class Overlay;
class PathRequests;
-class ProofOfWorkFactory;
class STLedgerEntry;
class TransactionMaster;
class Validations;
@@ -108,7 +107,6 @@ public:
virtual LoadFeeTrack& getFeeTrack () = 0;
virtual LoadManager& getLoadManager () = 0;
virtual Overlay& overlay () = 0;
- virtual ProofOfWorkFactory& getProofOfWorkFactory () = 0;
virtual UniqueNodeList& getUNL () = 0;
virtual Validations& getValidations () = 0;
virtual NodeStore::Database& getNodeStore () = 0;
diff --git a/src/ripple/app/misc/PowResult.h b/src/ripple/app/misc/PowResult.h
deleted file mode 100644
index 7db4bb4859..0000000000
--- a/src/ripple/app/misc/PowResult.h
+++ /dev/null
@@ -1,37 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of rippled: https://github.com/ripple/rippled
- Copyright (c) 2012, 2013 Ripple Labs Inc.
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#ifndef RIPPLE_POWRESULT_H_INCLUDED
-#define RIPPLE_POWRESULT_H_INCLUDED
-
-namespace ripple {
-
-enum PowResult
-{
- powOK = 0,
- powREUSED = 1, // already submitted
- powBADNONCE = 2, // you didn't solve it
- powEXPIRED = 3, // time is up
- powCORRUPT = 4,
- powTOOEASY = 5, // the difficulty increased too much while you solved it
-};
-
-}
-
-#endif
diff --git a/src/ripple/app/misc/ProofOfWork.cpp b/src/ripple/app/misc/ProofOfWork.cpp
deleted file mode 100644
index 7bcf32c01a..0000000000
--- a/src/ripple/app/misc/ProofOfWork.cpp
+++ /dev/null
@@ -1,205 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of rippled: https://github.com/ripple/rippled
- Copyright (c) 2012, 2013 Ripple Labs Inc.
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#include
-#include
-#include
-
-namespace ripple {
-
-// VFALCO TODO Move these to a header
-const uint256 ProofOfWork::sMinTarget ("00000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
-
-ProofOfWork::ProofOfWork (std::string const& token,
- int iterations,
- uint256 const& challenge,
- uint256 const& target)
- : mToken (token)
- , mChallenge (challenge)
- , mTarget (target)
- , mIterations (iterations)
-{
-}
-
-ProofOfWork::ProofOfWork (std::string const& token)
-{
- std::vector fields;
- boost::split (fields, token, boost::algorithm::is_any_of ("-"));
-
- if (fields.size () != 5)
- throw std::runtime_error ("invalid token");
-
- mToken = token;
- mChallenge.SetHex (fields[0]);
- mTarget.SetHex (fields[1]);
- mIterations = beast::lexicalCast (fields[2]);
-}
-
-bool ProofOfWork::isValid () const
-{
- if ((mIterations <= kMaxIterations) && (mTarget >= sMinTarget))
- return true;
-
- WriteLog (lsWARNING, ProofOfWork) << "Invalid PoW: " << mIterations << ", " << mTarget;
- return false;
-}
-
-std::uint64_t ProofOfWork::getDifficulty (uint256 const& target, int iterations)
-{
- // calculate the approximate number of hashes required to solve this proof of work
- if ((iterations > kMaxIterations) || (target < sMinTarget))
- {
- WriteLog (lsINFO, ProofOfWork) << "Iterations:" << iterations;
- WriteLog (lsINFO, ProofOfWork) << "MaxIterat: " << kMaxIterations;
- WriteLog (lsINFO, ProofOfWork) << "Target: " << target;
- WriteLog (lsINFO, ProofOfWork) << "MinTarget: " << sMinTarget;
- throw std::runtime_error ("invalid proof of work target/iteration");
- }
-
- // more iterations means more hashes per iteration but also a larger final hash
- std::uint64_t difficulty = iterations + (iterations / 8);
-
- // Multiply the number of hashes needed by 256 for each leading zero byte in the difficulty
- const unsigned char* ptr = target.begin ();
-
- while (*ptr == 0)
- {
- difficulty *= 256;
- ++ptr;
- }
-
- difficulty = (difficulty * 256) / (*ptr + 1);
-
- return difficulty;
-}
-
-static uint256 getSHA512Half (const std::vector& vec)
-{
- return Serializer::getSHA512Half (vec.front ().begin (), vec.size () * (256 / 8));
-}
-
-uint256 ProofOfWork::solve (int maxIterations) const
-{
- if (!isValid ())
- throw std::runtime_error ("invalid proof of work target/iteration");
-
- uint256 nonce;
- RandomNumbers::getInstance ().fill (&nonce);
-
- std::vector buf2;
- buf2.resize (mIterations);
-
- std::vector buf1;
- buf1.resize (3);
- buf1[0] = mChallenge;
-
- while (maxIterations > 0)
- {
- buf1[1] = nonce;
- buf1[2].zero ();
-
- for (int i = (mIterations - 1); i >= 0; --i)
- {
- buf1[2] = getSHA512Half (buf1);
- buf2[i] = buf1[2];
- }
-
- if (getSHA512Half (buf2) <= mTarget)
- return nonce;
-
- ++nonce;
- --maxIterations;
- }
-
- return uint256 ();
-}
-
-bool ProofOfWork::checkSolution (uint256 const& solution) const
-{
- if (mIterations > kMaxIterations)
- return false;
-
- std::vector buf1;
- buf1.push_back (mChallenge);
- buf1.push_back (solution);
- buf1.push_back (uint256 ());
-
- std::vector buf2;
- buf2.resize (mIterations);
-
- for (int i = (mIterations - 1); i >= 0; --i)
- {
- buf1[2] = getSHA512Half (buf1);
- buf2[i] = buf1[2];
- }
-
- return getSHA512Half (buf2) <= mTarget;
-}
-
-bool ProofOfWork::validateToken (std::string const& strToken)
-{
- static boost::regex const reToken (
- "[[:xdigit:]]{64}-"
- "[[:xdigit:]]{64}-"
- "[[:digit:]]+-"
- "[[:digit:]]+-"
- "[[:xdigit:]]{64}",
- boost::regex_constants::optimize);
-
- boost::smatch smMatch;
-
- return boost::regex_match (strToken, smMatch, reToken);
-}
-
-//------------------------------------------------------------------------------
-
-bool ProofOfWork::calcResultInfo (PowResult powCode, std::string& strToken, std::string& strHuman)
-{
- struct PowResultInfo
- {
- PowResult code;
- char const* token;
- char const* text;
- };
-
- static
- PowResultInfo const results[] =
- {
- { powOK, "powOK", "Valid proof-of-work." },
- { powREUSED, "powREUSED", "Proof-of-work has already been used." },
- { powBADNONCE, "powBADNONCE", "The solution does not meet the required difficulty." },
- { powEXPIRED, "powEXPIRED", "Token is expired." },
- { powCORRUPT, "powCORRUPT", "Invalid token." },
- { powTOOEASY, "powTOOEASY", "Difficulty has increased since token was issued." },
- };
-
- for (auto const& result : results)
- {
- if (powCode == result.code)
- {
- strToken = result.token;
- strHuman = result.text;
- return true;
- }
- }
-
- return false;
-}
-
-} // ripple
diff --git a/src/ripple/app/misc/ProofOfWork.h b/src/ripple/app/misc/ProofOfWork.h
deleted file mode 100644
index ad4a840f96..0000000000
--- a/src/ripple/app/misc/ProofOfWork.h
+++ /dev/null
@@ -1,82 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of rippled: https://github.com/ripple/rippled
- Copyright (c) 2012, 2013 Ripple Labs Inc.
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#ifndef RIPPLE_PROOFOFWORK_H
-#define RIPPLE_PROOFOFWORK_H
-
-#include
-
-namespace ripple {
-
-class ProofOfWork : beast::LeakChecked
-{
-public:
- enum
- {
- kMaxIterations = (1 << 23)
- };
-
- typedef std::shared_ptr pointer;
-
- ProofOfWork (std::string const& token,
- int iterations,
- uint256 const& challenge,
- uint256 const& target);
-
- explicit ProofOfWork (std::string const& token);
-
- bool isValid () const;
-
- uint256 solve (int maxIterations = 2 * kMaxIterations) const;
- bool checkSolution (uint256 const& solution) const;
-
- std::string const& getToken () const
- {
- return mToken;
- }
- uint256 const& getChallenge () const
- {
- return mChallenge;
- }
-
- std::uint64_t getDifficulty () const
- {
- return getDifficulty (mTarget, mIterations);
- }
-
- // approximate number of hashes needed to solve
- static std::uint64_t getDifficulty (uint256 const& target, int iterations);
-
- static bool validateToken (std::string const& strToken);
-
- static bool calcResultInfo (PowResult powCode, std::string& strToken, std::string& strHuman);
-
-private:
- std::string mToken;
- uint256 mChallenge;
- uint256 mTarget;
- int mIterations;
-
- static const uint256 sMinTarget;
- static const int maxIterations;
-};
-
-}
-
-#endif
diff --git a/src/ripple/app/misc/ProofOfWorkFactory.cpp b/src/ripple/app/misc/ProofOfWorkFactory.cpp
deleted file mode 100644
index 9c45cd1323..0000000000
--- a/src/ripple/app/misc/ProofOfWorkFactory.cpp
+++ /dev/null
@@ -1,428 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of rippled: https://github.com/ripple/rippled
- Copyright (c) 2012, 2013 Ripple Labs Inc.
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include //
-
-namespace ripple {
-
-class ProofOfWorkFactoryImp
- : public ProofOfWorkFactory
- , public beast::LeakChecked
-{
-public:
- typedef boost::bimaps::bimap< boost::bimaps::multiset_of,
- boost::bimaps::unordered_set_of > powMap_t;
-
- typedef powMap_t::value_type powMap_vt;
-
- //--------------------------------------------------------------------------
-
- ProofOfWorkFactoryImp ()
- : mValidTime (180)
- {
- setDifficulty (1);
- RandomNumbers::getInstance ().fillBytes (mSecret.begin (), mSecret.size ());
- }
-
- //--------------------------------------------------------------------------
-
- enum
- {
- numPowEntries = kMaxDifficulty + 1
- };
-
- struct PowEntry
- {
- const char* target;
- int iterations;
- };
-
- typedef std::vector PowEntries;
-
- static PowEntries const& getPowEntries ()
- {
- struct StaticPowEntries
- {
- StaticPowEntries ()
- {
- // VFALCO TODO Make this array know its own size.
- //
- PowEntry entries [numPowEntries] =
- {
- // target iterations hashes memory
- { "0CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 65536 }, // 1451874, 2 MB
- { "0CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 98304 }, // 2177811, 3 MB
- { "07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 98304 }, // 3538944, 3 MB
- { "0CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 196608}, // 4355623, 6 MB
-
- { "07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 131072}, // 4718592, 4 MB
- { "0CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 262144}, // 5807497, 8 MB
- { "07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 196608}, // 7077888, 6 MB
- { "07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 262144}, // 9437184, 8 MB
-
- { "07FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 393216}, // 14155776, 12MB
- { "03FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 393216}, // 28311552, 12MB
- { "00CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 262144}, // 92919965, 8 MB
- { "00CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 393216}, // 139379948, 12MB
-
- { "007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 262144}, // 150994944, 8 MB
- { "007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 393216}, // 226492416, 12MB
- { "000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 49152 }, // 278759896, 1.5MB
- { "003FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 262144}, // 301989888, 8 MB
-
- { "003FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 393216}, // 452984832, 12MB
- { "0007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 98304 }, // 905969664, 3 MB
- { "000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 196608}, // 1115039586, 6 MB
- { "000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 262144}, // 1486719448 8 MB
-
- { "000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 393216}, // 2230079172 12MB
- { "0007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 262144}, // 2415919104, 8 MB
- { "0007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 393216}, // 3623878656, 12MB
- { "0003FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 393216}, // 7247757312, 12MB
-
- { "0000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 262144}, // 23787511177, 8 MB
- { "0000CFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 393216}, // 35681266766, 12MB
- { "00003FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 131072}, // 38654705664, 4 MB
- { "00007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 262144}, // 38654705664, 8 MB
-
- { "00003FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 196608}, // 57982058496, 6 MB
- { "00007FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 393216}, // 57982058496, 12MB
- { "00003FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", 262144}, // 77309411328, 8 MB
- };
-
- data.reserve (numPowEntries);
-
- for (int i = 0; i < numPowEntries; ++i)
- data.push_back (entries [i]);
- }
-
- std::vector data;
- };
-
- static StaticPowEntries list;
-
- return list.data;
- }
-
- //--------------------------------------------------------------------------
-
- static int getPowEntry (uint256 const& target, int iterations)
- {
- PowEntries const& entries (getPowEntries ());
-
- for (int i = 0; i < numPowEntries; ++i)
- {
- if (entries [i].iterations == iterations)
- {
- uint256 t;
- t.SetHex (entries [i].target);
-
- if (t == target)
- return i;
- }
- }
-
- return -1;
- }
-
- //--------------------------------------------------------------------------
-
- ProofOfWork getProof ()
- {
- // challenge - target - iterations - time - validator
- static boost::format f ("%s-%s-%d-%d");
-
- int now = static_cast (time (nullptr) / 4);
-
- uint256 challenge;
- RandomNumbers::getInstance ().fillBytes (challenge.begin (), challenge.size ());
-
- ScopedLockType sl (mLock);
-
- std::string s = boost::str (boost::format (f) % to_string (challenge) %
- to_string (mTarget) % mIterations % now);
- std::string c = to_string (mSecret) + s;
- s += "-" + to_string (Serializer::getSHA512Half (c));
-
- return ProofOfWork (s, mIterations, challenge, mTarget);
- }
-
- //--------------------------------------------------------------------------
-
- PowResult checkProof (std::string const& token, uint256 const& solution)
- {
- // VFALCO COmmented this out because Dave said it wasn't used
- // and also we dont have the lexicalCast from a vector of strings to a time_t
-
- // challenge - target - iterations - time - validator
-
- std::vector fields;
- boost::split (fields, token, boost::algorithm::is_any_of ("-"));
-
- if (fields.size () != 5)
- {
- WriteLog (lsDEBUG, ProofOfWork) << "PoW " << token << " is corrupt";
- return powCORRUPT;
- }
-
- std::string v = to_string (mSecret) + fields[0] + "-" +
- fields[1] + "-" + fields[2] + "-" + fields[3];
-
- if (fields[4] != to_string (Serializer::getSHA512Half (v)))
- {
- WriteLog (lsDEBUG, ProofOfWork) << "PoW " << token << " has a bad token";
- return powCORRUPT;
- }
-
- uint256 challenge, target;
- challenge.SetHex (fields[0]);
- target.SetHex (fields[1]);
-
- time_t t;
- #if 0
- // Broken with lexicalCast<> changes
- t = beast::lexicalCast (fields[3]);
- #else
- t = static_cast (beast::lexicalCast (fields [3]));
- #endif
-
- time_t now = time (nullptr);
-
- int iterations = beast::lexicalCast (fields[2]);
-
- {
- ScopedLockType sl (mLock);
-
- if ((t * 4) > (now + mValidTime))
- {
- WriteLog (lsDEBUG, ProofOfWork) << "PoW " << token << " has expired";
- return powEXPIRED;
- }
-
- if (((iterations != mIterations) || (target != mTarget)) && getPowEntry (target, iterations) < (mPowEntry - 2))
- {
- // difficulty has increased more than two times since PoW requested
- WriteLog (lsINFO, ProofOfWork) << "Difficulty has increased since PoW requested";
- return powTOOEASY;
- }
- }
-
- ProofOfWork pow (token, iterations, challenge, target);
-
- if (!pow.checkSolution (solution))
- {
- WriteLog (lsDEBUG, ProofOfWork) << "PoW " << token << " has a bad nonce";
- return powBADNONCE;
- }
-
- {
- ScopedLockType sl (mLock);
-
- if (!mSolvedChallenges.insert (powMap_vt (now, challenge)).second)
- {
- WriteLog (lsDEBUG, ProofOfWork) << "PoW " << token << " has been reused";
- return powREUSED;
- }
- }
-
- return powOK;
- }
-
- //--------------------------------------------------------------------------
-
- void sweep ()
- {
- time_t expire = time (nullptr) - mValidTime;
-
- ScopedLockType sl (mLock);
-
- do
- {
- powMap_t::left_map::iterator it = mSolvedChallenges.left.begin ();
-
- if (it == mSolvedChallenges.left.end ())
- return;
-
- if (it->first >= expire)
- return;
-
- mSolvedChallenges.left.erase (it);
- }
- while (1);
- }
-
- //--------------------------------------------------------------------------
-
- void loadHigh ()
- {
- time_t now = time (nullptr);
-
- ScopedLockType sl (mLock);
-
- if (mLastDifficultyChange == now)
- return;
-
- if (mPowEntry == 30)
- return;
-
- ++mPowEntry;
- mLastDifficultyChange = now;
- }
-
- //--------------------------------------------------------------------------
-
- void loadLow ()
- {
- time_t now = time (nullptr);
-
- ScopedLockType sl (mLock);
-
- if (mLastDifficultyChange == now)
- return;
-
- if (mPowEntry == 0)
- return;
-
- --mPowEntry;
- mLastDifficultyChange = now;
- }
-
- //--------------------------------------------------------------------------
-
- void setDifficulty (int i)
- {
- assert ((i >= 0) && (i <= kMaxDifficulty));
- time_t now = time (nullptr);
-
- ScopedLockType sl (mLock);
- mPowEntry = i;
- PowEntries const& entries (getPowEntries ());
- mIterations = entries [i].iterations;
- mTarget.SetHex (entries [i].target);
- mLastDifficultyChange = now;
- }
-
- //--------------------------------------------------------------------------
-
- std::uint64_t getDifficulty ()
- {
- return ProofOfWork::getDifficulty (mTarget, mIterations);
- }
-
- uint256 const& getSecret () const
- {
- return mSecret;
- }
-
- void setSecret (uint256 const& secret)
- {
- mSecret = secret;
- }
-
-private:
- typedef RippleMutex LockType;
- typedef std::lock_guard ScopedLockType;
- LockType mLock;
-
- uint256 mSecret;
- int mIterations;
- uint256 mTarget;
- time_t mLastDifficultyChange;
- int mValidTime;
- int mPowEntry;
-
- powMap_t mSolvedChallenges;
-};
-
-//------------------------------------------------------------------------------
-
-std::unique_ptr make_ProofOfWorkFactory ()
-{
- return std::make_unique();
-}
-
-//------------------------------------------------------------------------------
-
-class ProofOfWork_test : public beast::unit_test::suite
-{
-public:
- void run ()
- {
- using namespace ripple;
-
- ProofOfWorkFactoryImp gen;
- ProofOfWork pow = gen.getProof ();
-
- uint256 solution = pow.solve (16777216);
-
- expect (! solution.isZero (), "Should be solved");
-
- expect (pow.checkSolution (solution), "Should be checked");
-
- // Why is this emitted?
- //WriteLog (lsDEBUG, ProofOfWork) << "A bad nonce error is expected";
-
- PowResult r = gen.checkProof (pow.getToken (), uint256 ());
-
- expect (r == powBADNONCE, "Should show bad nonce for empty solution");
-
- expect (gen.checkProof (pow.getToken (), solution) == powOK, "Solution should check with issuer");
-
- //WriteLog (lsDEBUG, ProofOfWork) << "A reused nonce error is expected";
-
- expect (gen.checkProof (pow.getToken (), solution) == powREUSED, "Reuse solution should be detected");
-
- #ifdef SOLVE_POWS
-
- for (int i = 0; i < 12; ++i)
- {
- gen.setDifficulty (i);
- ProofOfWork pow = gen.getProof ();
- WriteLog (lsINFO, ProofOfWork) << "Level: " << i << ", Estimated difficulty: " << pow.getDifficulty ();
- uint256 solution = pow.solve (131072);
-
- if (solution.isZero ())
- {
- //WriteLog (lsINFO, ProofOfWork) << "Giving up";
- }
- else
- {
- //WriteLog (lsINFO, ProofOfWork) << "Solution found";
-
- if (gen.checkProof (pow.getToken (), solution) != powOK)
- {
- //WriteLog (lsFATAL, ProofOfWork) << "Solution fails";
- }
- }
- }
-
- #endif
- }
-};
-
-BEAST_DEFINE_TESTSUITE_MANUAL(ProofOfWork,ripple_app,ripple);
-
-} // ripple
diff --git a/src/ripple/app/misc/ProofOfWorkFactory.h b/src/ripple/app/misc/ProofOfWorkFactory.h
deleted file mode 100644
index e1ad8c37b5..0000000000
--- a/src/ripple/app/misc/ProofOfWorkFactory.h
+++ /dev/null
@@ -1,64 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of rippled: https://github.com/ripple/rippled
- Copyright (c) 2012, 2013 Ripple Labs Inc.
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#ifndef RIPPLE_PROOFOFWORKFACTORY_H_INCLUDED
-#define RIPPLE_PROOFOFWORKFACTORY_H_INCLUDED
-
-#include
-#include
-#include
-#include //
-#include
-
-namespace ripple {
-
-class ProofOfWorkFactory
-{
-public:
- enum
- {
- kMaxDifficulty = 30,
- };
-
- virtual ~ProofOfWorkFactory () { }
-
- virtual ProofOfWork getProof () = 0;
-
- virtual PowResult checkProof (std::string const& token, uint256 const& solution) = 0;
-
- virtual std::uint64_t getDifficulty () = 0;
-
- virtual void setDifficulty (int i) = 0;
-
- virtual void loadHigh () = 0;
-
- virtual void loadLow () = 0;
-
- virtual void sweep () = 0;
-
- virtual uint256 const& getSecret () const = 0;
-
- virtual void setSecret (uint256 const& secret) = 0;
-};
-
-std::unique_ptr make_ProofOfWorkFactory ();
-
-}
-
-#endif
diff --git a/src/ripple/overlay/impl/PeerImp.cpp b/src/ripple/overlay/impl/PeerImp.cpp
index 241e38a101..85adca0f1d 100644
--- a/src/ripple/overlay/impl/PeerImp.cpp
+++ b/src/ripple/overlay/impl/PeerImp.cpp
@@ -856,74 +856,6 @@ PeerImp::onMessage (std::shared_ptr const& m)
}
}
-void
-PeerImp::onMessage (std::shared_ptr const& m)
-{
- if (m->has_response ())
- {
- // this is an answer to a proof of work we requested
- if (m->response ().size () != (256 / 8))
- return charge (Resource::feeInvalidRequest);
-
- uint256 response;
- memcpy (response.begin (), m->response ().data (), 256 / 8);
-
- // VFALCO TODO Use a dependency injection here
- PowResult r = getApp().getProofOfWorkFactory ().checkProof (
- m->token (), response);
-
- if (r == powOK)
- // credit peer
- // WRITEME
- return;
-
- // return error message
- // WRITEME
- if (r != powTOOEASY)
- charge (Resource::feeBadProofOfWork);
-
- return;
- }
-
- if (m->has_result ())
- {
- // this is a reply to a proof of work we sent
- // WRITEME
- }
-
- if (m->has_target () && m->has_challenge () && m->has_iterations ())
- {
- // this is a challenge
- // WRITEME: Reject from inbound connections
-
- uint256 challenge, target;
-
- if ((m->challenge ().size () != (256 / 8)) || (
- m->target ().size () != (256 / 8)))
- return charge (Resource::feeInvalidRequest);
-
- memcpy (challenge.begin (), m->challenge ().data (), 256 / 8);
- memcpy (target.begin (), m->target ().data (), 256 / 8);
- ProofOfWork::pointer pow = std::make_shared (
- m->token (), m->iterations (), challenge, target);
-
- if (!pow->isValid ())
- return charge (Resource::feeInvalidRequest);
-
-#if 0 // Until proof of work is completed, don't do it
- getApp().getJobQueue ().addJob (
- jtPROOFWORK,
- "recvProof->doProof",
- std::bind (&PeerImp::doProofOfWork, std::placeholders::_1,
- std::weak_ptr (shared_from_this ()), pow));
-#endif
-
- return;
- }
-
- p_journal_.info << "Bad proof of work";
-}
-
void
PeerImp::onMessage (std::shared_ptr const& m)
{
@@ -1621,38 +1553,6 @@ PeerImp::doFetchPack (const std::shared_ptr& packet
packet, hash, UptimeTimer::getInstance ().getElapsedSeconds ()));
}
-void
-PeerImp::doProofOfWork (Job&, std::weak_ptr peer,
- ProofOfWork::pointer pow)
-{
- if (peer.expired ())
- return;
-
- uint256 solution = pow->solve ();
-
- if (solution.isZero ())
- {
- p_journal_.warning << "Failed to solve proof of work";
- }
- else
- {
- Peer::ptr pptr (peer.lock ());
-
- if (pptr)
- {
- protocol::TMProofWork reply;
- reply.set_token (pow->getToken ());
- reply.set_response (solution.begin (), solution.size ());
- pptr->send (std::make_shared (
- reply, protocol::mtPROOFOFWORK));
- }
- else
- {
- // WRITEME: Save solved proof of work for new connection
- }
- }
-}
-
void
PeerImp::checkTransaction (Job&, int flags,
STTx::pointer stx)
diff --git a/src/ripple/overlay/impl/PeerImp.h b/src/ripple/overlay/impl/PeerImp.h
index 715ef1afc4..82927387d8 100644
--- a/src/ripple/overlay/impl/PeerImp.h
+++ b/src/ripple/overlay/impl/PeerImp.h
@@ -24,8 +24,6 @@
#include
#include
#include
-#include
-#include
#include
#include
#include
@@ -371,7 +369,6 @@ public:
void onMessage (std::shared_ptr const& m);
void onMessage (std::shared_ptr const& m);
- void onMessage (std::shared_ptr const& m);
void onMessage (std::shared_ptr const& m);
void onMessage (std::shared_ptr const& m);
void onMessage (std::shared_ptr const& m);
@@ -421,9 +418,6 @@ private:
void
doFetchPack (const std::shared_ptr& packet);
- void
- doProofOfWork (Job&, std::weak_ptr peer, ProofOfWork::pointer pow);
-
void
checkTransaction (Job&, int flags, STTx::pointer stx);
diff --git a/src/ripple/overlay/impl/ProtocolMessage.h b/src/ripple/overlay/impl/ProtocolMessage.h
index 429d1b8152..dde1a6c2b0 100644
--- a/src/ripple/overlay/impl/ProtocolMessage.h
+++ b/src/ripple/overlay/impl/ProtocolMessage.h
@@ -113,7 +113,6 @@ invokeProtocolMessage (Buffers const& buffers, Handler& handler)
{
case protocol::mtHELLO: ec = detail::invoke (type, buffers, handler); break;
case protocol::mtPING: ec = detail::invoke (type, buffers, handler); break;
- case protocol::mtPROOFOFWORK: ec = detail::invoke (type, buffers, handler); break;
case protocol::mtCLUSTER: ec = detail::invoke (type, buffers, handler); break;
case protocol::mtGET_PEERS: ec = detail::invoke (type, buffers, handler); break;
case protocol::mtPEERS: ec = detail::invoke (type, buffers, handler); break;
diff --git a/src/ripple/resource/Fees.h b/src/ripple/resource/Fees.h
index 9a537ce09d..7a66d61143 100644
--- a/src/ripple/resource/Fees.h
+++ b/src/ripple/resource/Fees.h
@@ -31,7 +31,6 @@ extern Charge const feeInvalidRequest; // A request that we can immediate
extern Charge const feeRequestNoReply; // A request that we cannot satisfy
extern Charge const feeInvalidSignature; // An object whose signature we had to check and it failed
extern Charge const feeUnwantedData; // Data we have no use for
-extern Charge const feeBadProofOfWork; // Proof of work not valid
extern Charge const feeBadData; // Data we have to verify before rejecting
// RPC loads
diff --git a/src/ripple/resource/LegacyFees.h b/src/ripple/resource/LegacyFees.h
index 523a02fddf..3323c53f05 100644
--- a/src/ripple/resource/LegacyFees.h
+++ b/src/ripple/resource/LegacyFees.h
@@ -31,7 +31,6 @@ enum LoadType
LT_RequestNoReply, // A request that we cannot satisfy
LT_InvalidSignature, // An object whose signature we had to check and it failed
LT_UnwantedData, // Data we have no use for
- LT_BadPoW, // Proof of work not valid
LT_BadData, // Data we have to verify before rejecting
// RPC loads
diff --git a/src/ripple/resource/impl/Fees.cpp b/src/ripple/resource/impl/Fees.cpp
index 3892479ecc..cad0983505 100644
--- a/src/ripple/resource/impl/Fees.cpp
+++ b/src/ripple/resource/impl/Fees.cpp
@@ -26,7 +26,6 @@ Charge const feeInvalidRequest ( 10, "malformed request" );
Charge const feeRequestNoReply ( 1, "unsatisfiable request" );
Charge const feeInvalidSignature ( 100, "invalid signature" );
Charge const feeUnwantedData ( 5, "useless data" );
-Charge const feeBadProofOfWork ( 250, "incorrect proof of work"); // DAVID: Check the cost
Charge const feeBadData ( 20, "invalid data" );
Charge const feeInvalidRPC ( 10, "malformed RPC" );
diff --git a/src/ripple/resource/impl/LegacyFees.cpp b/src/ripple/resource/impl/LegacyFees.cpp
index d1baeb4ecf..1164cb5908 100644
--- a/src/ripple/resource/impl/LegacyFees.cpp
+++ b/src/ripple/resource/impl/LegacyFees.cpp
@@ -30,7 +30,6 @@ Charge legacyFee (LoadType t)
case LT_RequestNoReply: return feeRequestNoReply;
case LT_InvalidSignature: return feeInvalidSignature;
case LT_UnwantedData: return feeUnwantedData;
- case LT_BadPoW: return feeBadProofOfWork;
case LT_BadData: return feeBadData;
case LT_RPCInvalid: return feeInvalidRPC;
diff --git a/src/ripple/rpc/handlers/Handlers.h b/src/ripple/rpc/handlers/Handlers.h
index ca08c1d898..c39ebd920c 100644
--- a/src/ripple/rpc/handlers/Handlers.h
+++ b/src/ripple/rpc/handlers/Handlers.h
@@ -53,9 +53,6 @@ Json::Value doPathFind (RPC::Context&);
Json::Value doPeers (RPC::Context&);
Json::Value doPing (RPC::Context&);
Json::Value doPrint (RPC::Context&);
-Json::Value doProofCreate (RPC::Context&);
-Json::Value doProofSolve (RPC::Context&);
-Json::Value doProofVerify (RPC::Context&);
Json::Value doRandom (RPC::Context&);
Json::Value doRipplePathFind (RPC::Context&);
Json::Value doSMS (RPC::Context&);
diff --git a/src/ripple/rpc/handlers/ProofCreate.cpp b/src/ripple/rpc/handlers/ProofCreate.cpp
deleted file mode 100644
index 964a10f8ea..0000000000
--- a/src/ripple/rpc/handlers/ProofCreate.cpp
+++ /dev/null
@@ -1,74 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of rippled: https://github.com/ripple/rippled
- Copyright (c) 2012-2014 Ripple Labs Inc.
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-#include
-
-namespace ripple {
-
-// {
-// // if either of these parameters is set, a custom generator is used
-// difficulty: // optional
-// secret: // optional
-// }
-Json::Value doProofCreate (RPC::Context& context)
-{
- // XXX: Add ability to create proof with arbitrary time
- Json::Value jvResult (Json::objectValue);
-
- if (context.params.isMember ("difficulty") ||
- context.params.isMember ("secret"))
- {
- // VFALCO TODO why aren't we using the app's factory?
- auto pgGen = make_ProofOfWorkFactory ();
-
- if (context.params.isMember ("difficulty"))
- {
- if (!context.params["difficulty"].isIntegral ())
- return RPC::invalid_field_error ("difficulty");
-
- int const iDifficulty (context.params["difficulty"].asInt ());
-
- if (iDifficulty < 0 ||
- iDifficulty > ProofOfWorkFactory::kMaxDifficulty)
- {
- return RPC::invalid_field_error ("difficulty");
- }
-
- pgGen->setDifficulty (iDifficulty);
- }
-
- if (context.params.isMember ("secret"))
- {
- uint256 uSecret (context.params["secret"].asString ());
- pgGen->setSecret (uSecret);
- }
-
- jvResult["token"] = pgGen->getProof ().getToken ();
- jvResult["secret"] = to_string (pgGen->getSecret ());
- }
- else
- {
- jvResult["token"]
- = getApp().getProofOfWorkFactory ().getProof ().getToken ();
- }
-
- return jvResult;
-}
-
-} // ripple
diff --git a/src/ripple/rpc/handlers/ProofSolve.cpp b/src/ripple/rpc/handlers/ProofSolve.cpp
deleted file mode 100644
index 8e8ab80288..0000000000
--- a/src/ripple/rpc/handlers/ProofSolve.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of rippled: https://github.com/ripple/rippled
- Copyright (c) 2012-2014 Ripple Labs Inc.
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-
-namespace ripple {
-
-// {
-// token:
-// }
-Json::Value doProofSolve (RPC::Context& context)
-{
- Json::Value jvResult;
-
- if (!context.params.isMember ("token"))
- return RPC::missing_field_error ("token");
-
- std::string strToken = context.params["token"].asString ();
-
- if (!ProofOfWork::validateToken (strToken))
- return RPC::invalid_field_error ("token");
-
- ProofOfWork powProof (strToken);
- uint256 uSolution = powProof.solve ();
-
- jvResult["solution"] = to_string (uSolution);
-
- return jvResult;
-}
-
-} // ripple
diff --git a/src/ripple/rpc/handlers/ProofVerify.cpp b/src/ripple/rpc/handlers/ProofVerify.cpp
deleted file mode 100644
index eab15487d9..0000000000
--- a/src/ripple/rpc/handlers/ProofVerify.cpp
+++ /dev/null
@@ -1,97 +0,0 @@
-//------------------------------------------------------------------------------
-/*
- This file is part of rippled: https://github.com/ripple/rippled
- Copyright (c) 2012-2014 Ripple Labs Inc.
-
- Permission to use, copy, modify, and/or distribute this software for any
- purpose with or without fee is hereby granted, provided that the above
- copyright notice and this permission notice appear in all copies.
-
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-*/
-//==============================================================================
-
-
-namespace ripple {
-
-// {
-// token:
-// solution:
-// // if either of these parameters is set, a custom verifier is used
-// difficulty: // optional
-// secret: // optional
-// }
-Json::Value doProofVerify (RPC::Context& context)
-{
- // XXX Add ability to check proof against arbitrary time
-
- Json::Value jvResult;
-
- if (!context.params.isMember ("token"))
- return RPC::missing_field_error ("token");
-
- if (!context.params.isMember ("solution"))
- return RPC::missing_field_error ("solution");
-
- std::string strToken = context.params["token"].asString ();
- uint256 uSolution (context.params["solution"].asString ());
-
- PowResult prResult;
-
- if (context.params.isMember ("difficulty") ||
- context.params.isMember ("secret"))
- {
- // VFALCO TODO why aren't we using the app's factory?
- auto pgGen = make_ProofOfWorkFactory ();
-
- if (context.params.isMember ("difficulty"))
- {
- if (!context.params["difficulty"].isIntegral ())
- return RPC::invalid_field_error ("difficulty");
-
- int iDifficulty = context.params["difficulty"].asInt ();
-
- if (iDifficulty < 0 ||
- iDifficulty > ProofOfWorkFactory::kMaxDifficulty)
- {
- return RPC::invalid_field_error ("difficulty");
- }
-
- pgGen->setDifficulty (iDifficulty);
- }
-
- if (context.params.isMember ("secret"))
- {
- uint256 uSecret (context.params["secret"].asString ());
- pgGen->setSecret (uSecret);
- }
-
- prResult = pgGen->checkProof (strToken, uSolution);
- jvResult["secret"] = to_string (pgGen->getSecret ());
- }
- else
- {
- // XXX Proof should not be marked as used from this
- prResult = getApp().getProofOfWorkFactory ().checkProof (
- strToken, uSolution);
- }
-
- std::string sToken;
- std::string sHuman;
-
- ProofOfWork::calcResultInfo (prResult, sToken, sHuman);
-
- jvResult["proof_result"] = sToken;
- jvResult["proof_result_code"] = prResult;
- jvResult["proof_result_message"] = sHuman;
-
- return jvResult;
-}
-
-} // ripple
diff --git a/src/ripple/rpc/impl/Handler.cpp b/src/ripple/rpc/impl/Handler.cpp
index ebcae21fd2..6d632f844c 100644
--- a/src/ripple/rpc/impl/Handler.cpp
+++ b/src/ripple/rpc/impl/Handler.cpp
@@ -117,9 +117,6 @@ HandlerTable HANDLERS({
{ "ping", byRef (&doPing), Role::USER, NO_CONDITION },
{ "print", byRef (&doPrint), Role::ADMIN, NO_CONDITION },
// { "profile", byRef (&doProfile), Role::USER, NEEDS_CURRENT_LEDGER },
- { "proof_create", byRef (&doProofCreate), Role::ADMIN, NO_CONDITION },
- { "proof_solve", byRef (&doProofSolve), Role::ADMIN, NO_CONDITION },
- { "proof_verify", byRef (&doProofVerify), Role::ADMIN, NO_CONDITION },
{ "random", byRef (&doRandom), Role::USER, NO_CONDITION },
{ "ripple_path_find", byRef (&doRipplePathFind), Role::USER, NEEDS_CURRENT_LEDGER },
{ "sign", byRef (&doSign), Role::USER, NO_CONDITION },
@@ -143,6 +140,7 @@ HandlerTable HANDLERS({
{ "wallet_accounts", byRef (&doWalletAccounts), Role::USER, NEEDS_CURRENT_LEDGER },
{ "wallet_propose", byRef (&doWalletPropose), Role::ADMIN, NO_CONDITION },
{ "wallet_seed", byRef (&doWalletSeed), Role::ADMIN, NO_CONDITION },
+
// Evented methods
{ "subscribe", byRef (&doSubscribe), Role::USER, NO_CONDITION },
{ "unsubscribe", byRef (&doUnsubscribe), Role::USER, NO_CONDITION },
diff --git a/src/ripple/unity/app1.cpp b/src/ripple/unity/app1.cpp
index 0e3d45505b..67b4a6a063 100644
--- a/src/ripple/unity/app1.cpp
+++ b/src/ripple/unity/app1.cpp
@@ -20,9 +20,6 @@
#include
#include
-#include
-#include
-#include
#include
#include
#include
diff --git a/src/ripple/unity/rpcx.cpp b/src/ripple/unity/rpcx.cpp
index d85ba91cb5..f32d92bad2 100644
--- a/src/ripple/unity/rpcx.cpp
+++ b/src/ripple/unity/rpcx.cpp
@@ -73,9 +73,6 @@
#include
#include
#include
-#include
-#include
-#include
#include
#include
#include