#include <tnlClientPuzzle.h>
Public Types | |
enum | ErrorCode { Success, InvalidSolution, InvalidServerNonce, InvalidClientNonce, InvalidPuzzleDifficulty, ErrorCodeCount } |
Error codes that can be returned by checkSolution. More... | |
enum | { PuzzleRefreshTime = 30000, InitialPuzzleDifficulty = 17, MaxPuzzleDifficulty = 26, MaxSolutionComputeFragment = 30, SolutionFragmentIterations = 50000 } |
Difficulty levels of puzzles. More... | |
Public Member Functions | |
ClientPuzzleManager () | |
~ClientPuzzleManager () | |
void | tick (U32 currentTime) |
Checks to see if a new nonce needs to be created, and if so generates one and tosses out the current list of accepted nonces. | |
ErrorCode | checkSolution (U32 solution, Nonce &clientNonce, Nonce &serverNonce, U32 puzzleDifficulty, U32 clientIdentity) |
Checks a puzzle solution submitted by a client to see if it is a valid solution for the current or previous puzzle nonces. | |
Nonce | getCurrentNonce () |
Returns the current server nonce. | |
U32 | getCurrentDifficulty () |
Returns the current client puzzle difficulty. | |
Static Public Member Functions | |
bool | solvePuzzle (U32 *solution, Nonce &clientNonce, Nonce &serverNonce, U32 puzzleDifficulty, U32 clientIdentity) |
Computes a puzzle solution value for the given puzzle difficulty and server nonce. | |
Static Private Member Functions | |
bool | checkOneSolution (U32 solution, Nonce &clientNonce, Nonce &serverNonce, U32 puzzleDifficulty, U32 clientIdentity) |
Private Attributes | |
U32 | mCurrentDifficulty |
U32 | mLastUpdateTime |
U32 | mLastTickTime |
Nonce | mCurrentNonce |
Nonce | mLastNonce |
NonceTable * | mCurrentNonceTable |
NonceTable * | mLastNonceTable |
|
Error codes that can be returned by checkSolution.
|
|
|
|
|
|
|
|
|
Checks to see if a new nonce needs to be created, and if so generates one and tosses out the current list of accepted nonces.
|
|
Checks a puzzle solution submitted by a client to see if it is a valid solution for the current or previous puzzle nonces.
|
|
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.
|
|
Returns the current server nonce.
|
|
Returns the current client puzzle difficulty.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|