Initial validation
This commit is contained in:
@@ -2517,7 +2517,7 @@ void sudoku_gen(uint8_t key32[32],uint8_t unsolved[9][9],uint32_t srandi)
|
||||
cclib solution 17 \"[%224d50336780d5a300a1f01b12fe36f46a82f3b9935bb115e01e0113dc4f337aae%22,%22234791685716258943589643712865934127341827596927516438492375861178462359653189274%22,0,0,1548859143,1548859146,0,1548859146,0,1548859148,1548859149,0,1548859151,1548859152,0,1548859154,1548859155,1548859158,1548859159,0,0,0,1548859161,1548859163,0,1548859164,1548859168,0,1548859168,1548859170,1548859172,1548859172,1548859175,0,0,1548859176,0,0,1548859178,1548859178,0,0,1548859180,1548859181,1548859183,1548859184,1548859185,1548859186,1548859188,1548859190,1548859191,1548859192,1548859192,0,0,1548859195,1548859196,1548859197,1548859198,0,0,1548859199,1548859202,1548859202,0,1548859204,1548859205,1548859206,1548859209,1548859210,1548859211,1548859212,0,1548859214,1548859216,0,1548859217,1548859218,1548859219,1548859220,0,1548859222,1548859222]\"
|
||||
*/
|
||||
|
||||
int32_t sudoku_captcha(uint32_t timestamps[81],int32_t height)
|
||||
int32_t sudoku_captcha(int32_t dispflag,uint32_t timestamps[81],int32_t height)
|
||||
{
|
||||
int32_t i,solvetime,diff,avetime,n = 0,retval = 0; uint64_t variance = 0; std::vector<uint32_t> list;
|
||||
for (i=0; i<81; i++)
|
||||
@@ -2549,20 +2549,22 @@ int32_t sudoku_captcha(uint32_t timestamps[81],int32_t height)
|
||||
for (i=0; i<n-1; i++)
|
||||
{
|
||||
diff = (list[i+1] - list[i]);
|
||||
printf("%d ",diff);
|
||||
if ( dispflag != 0 )
|
||||
printf("%d ",diff);
|
||||
diff -= avetime;
|
||||
variance += (diff * diff);
|
||||
}
|
||||
variance /= (n - 1);
|
||||
printf("solvetime.%d n.%d avetime.%d variance.%llu vs ave2 %d\n",solvetime,n,avetime,(long long)variance,avetime*avetime);
|
||||
if ( dispflag != 0 )
|
||||
printf("solvetime.%d n.%d avetime.%d variance.%llu vs ave2 %d\n",solvetime,n,avetime,(long long)variance,avetime*avetime);
|
||||
if ( variance < avetime )
|
||||
retval = -5;
|
||||
else return(0);
|
||||
}
|
||||
} else retval = -6;
|
||||
if ( retval != 0 )
|
||||
if ( dispflag != 0 && retval != 0 )
|
||||
fprintf(stderr,"ERR >>>>>>>>>>>>>>> ht.%d retval.%d\n",height,retval);
|
||||
if ( height < 2000 )
|
||||
if ( height <= 2036 )
|
||||
return(0);
|
||||
else return(retval);
|
||||
}
|
||||
@@ -2863,7 +2865,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params
|
||||
result.push_back(Pair("sudokuaddr",CCaddr));
|
||||
balance = CCaddress_balance(CCaddr);
|
||||
result.push_back(Pair("amount",ValueFromAmount(balance)));
|
||||
if ( sudoku_captcha(timestamps,komodo_nextheight()) < 0 )
|
||||
if ( sudoku_captcha(1,timestamps,komodo_nextheight()) < 0 )
|
||||
{
|
||||
result.push_back(Pair("result","error"));
|
||||
result.push_back(Pair("error","captcha failure"));
|
||||
@@ -3024,11 +3026,12 @@ bool sudoku_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const
|
||||
{
|
||||
if ( dispflag != 0 )
|
||||
fprintf(stderr,"non-unique sudoku at ht.%d\n",height);
|
||||
return eval->Invalid("invalid sudoku with multiple solutions");
|
||||
if ( strcmp(ASSETCHAINS_SYMBOL,"SUDOKU") != 0 )
|
||||
return eval->Invalid("invalid sudoku with multiple solutions");
|
||||
}
|
||||
if ( dispflag != 0 )
|
||||
fprintf(stderr,"%s score.%d %s\n",solution,score,unsolved);
|
||||
if ( sudoku_captcha(timestamps,height) < 0 )
|
||||
if ( sudoku_captcha(dispflag,timestamps,height) < 0 )
|
||||
return eval->Invalid("failed captcha");
|
||||
/*for (i=lasttime=0; i<81; i++)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user