[Opentnl-cvs] tnl/tnl clientPuzzle.cpp,1.3,1.4 tnlClientPuzzle.h,1.1,1.2
Brought to you by:
mark_frohnmayer,
s_alanet
From: Ben G. <s_a...@us...> - 2004-04-23 22:02:59
|
Update of /cvsroot/opentnl/tnl/tnl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19912/tnl Modified Files: clientPuzzle.cpp tnlClientPuzzle.h Log Message: Documented and cleaned up client puzzle header. Changed iterations per client puzzle fragment back to 50k after inadvertant checkin of test value. Index: tnlClientPuzzle.h =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/tnlClientPuzzle.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tnlClientPuzzle.h 20 Apr 2004 04:27:18 -0000 1.1 --- tnlClientPuzzle.h 23 Apr 2004 22:02:47 -0000 1.2 *************** *** 10,15 **** // (at your option) any later version. // ! // For use in products that are not compatible with the terms of the GNU ! // General Public License, alternative licensing options are available // from GarageGames.com. // --- 10,15 ---- // (at your option) any later version. // ! // For use in products that are not compatible with the terms of the GNU ! // General Public License, alternative licensing options are available // from GarageGames.com. // *************** *** 46,52 **** /// NonceTable manages the list of client nonces for which clients /// have constructed valid puzzle solutions for the current server ! /// nonce. There are 2 nonce tables in the ClientPuzzleManager - /// one for the current nonce and one for the previous nonce. ! class NonceTable { private: --- 46,52 ---- /// NonceTable manages the list of client nonces for which clients /// have constructed valid puzzle solutions for the current server ! /// nonce. There are 2 nonce tables in the ClientPuzzleManager - /// one for the current nonce and one for the previous nonce. ! class NonceTable { private: *************** *** 77,84 **** }; - enum { - PuzzleRefreshTime = 30000, ///< Refresh the server puzzle every 30 seconds - }; - U32 mCurrentDifficulty; U32 mLastUpdateTime; --- 77,80 ---- *************** *** 111,117 **** /// Difficulty levels of puzzles enum { ! InitialPuzzleDifficulty = 17, ///< Initial puzzle difficulty is set so clients do approx 2-3x the shared secret generation of the server ! MaxPuzzleDifficulty = 26, ///< Maximum puzzle diffuclty is approx 1 minute to solve on ~2004 hardware. ! MaxSolutionComputeFragment = 30, ///< Number of milliseconds spent computing a solution per call to solvePuzzle. }; --- 107,116 ---- /// Difficulty levels of puzzles enum { ! PuzzleRefreshTime = 30000, ///< Refresh the server puzzle every 30 seconds ! InitialPuzzleDifficulty = 17, ///< Initial puzzle difficulty is set so clients do approx 2-3x the shared secret ! /// generation of the server ! MaxPuzzleDifficulty = 26, ///< Maximum puzzle difficulty is approx 1 minute to solve on ~2004 hardware. ! MaxSolutionComputeFragment = 30, ///< Number of milliseconds spent computing solution per call to solvePuzzle. ! SolutionFragmentIterations = 50000, ///< Number of attempts to spend on the client puzzle per call to solvePuzzle. }; *************** *** 120,124 **** /// Computes a puzzle solution value for the given puzzle difficulty and server nonce. If the execution time of this function ! /// exceeds 30 milliseconds, it will return the current trail solution in the solution variable and a return value of false. static bool solvePuzzle(U32 *solution, Nonce &clientNonce, Nonce &serverNonce, U32 puzzleDifficulty, U32 clientIdentity); --- 119,134 ---- /// Computes a puzzle solution value for the given puzzle difficulty and server nonce. If the execution time of this function ! /// exceeds MaxSolutionComputeFragment milliseconds, it will return the current trail solution in the solution variable and a ! /// return value of false. ! /// ! /// @note Although the behavior of this function can be tweaked using MaxSolutionComputeFragment and ! /// SolutionFragmentIterations, it's important to bias these settings in favor of rapid puzzle ! /// completion. A client puzzle is only valid for two times PuzzleRefreshTime, so for about a ! /// minute, maximum. Most of the time the puzzle can be solved in only a few hundred ! /// milliseconds. It's better to solve the puzzle fast than to let it drag out, (ie, it's better to ! /// let your application hitch for a moment whilst calculating than to make the user endure many ! /// seconds of lag) so reducing the timeout or iterations should be done only if you know what ! /// you're doing. ! /// static bool solvePuzzle(U32 *solution, Nonce &clientNonce, Nonce &serverNonce, U32 puzzleDifficulty, U32 clientIdentity); Index: clientPuzzle.cpp =================================================================== RCS file: /cvsroot/opentnl/tnl/tnl/clientPuzzle.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** clientPuzzle.cpp 23 Apr 2004 08:10:02 -0000 1.3 --- clientPuzzle.cpp 23 Apr 2004 22:02:38 -0000 1.4 *************** *** 10,15 **** // (at your option) any later version. // ! // For use in products that are not compatible with the terms of the GNU ! // General Public License, alternative licensing options are available // from GarageGames.com. // --- 10,15 ---- // (at your option) any later version. // ! // For use in products that are not compatible with the terms of the GNU ! // General Public License, alternative licensing options are available // from GarageGames.com. // *************** *** 158,163 **** for(;;) { ! // We do 50,000 attempts... (this valus is tweakable) ! U32 nextValue = startValue + 50000; for(;startValue < nextValue; startValue++) { --- 158,162 ---- for(;;) { ! U32 nextValue = startValue + SolutionFragmentIterations; for(;startValue < nextValue; startValue++) { |