@@ -52,8 +52,7 @@ typedef struct {
5252
5353 uint64_t totalkeys = 0 ;
5454 unsigned int elapsed = 0 ;
55- uint64_t stride = 1 ;
56-
55+ secp256k1::uint256 stride = 1 ;
5756}RunConfig;
5857
5958static RunConfig _config;
@@ -309,7 +308,7 @@ void writeCheckpoint(secp256k1::uint256 nextKey)
309308 tmp << " compression=" << getCompressionString (_config.compression ) << std::endl;
310309 tmp << " device=" << _config.device << std::endl;
311310 tmp << " elapsed=" << (_config.elapsed + util::getSystemTime () - _startTime) << std::endl;
312- tmp << " stride=" << ( _config.stride );
311+ tmp << " stride=" << _config.stride . toString ( );
313312 tmp.close ();
314313}
315314
@@ -365,7 +364,7 @@ int run()
365364 Logger::log (LogLevel::Info, " Compression: " + getCompressionString (_config.compression ));
366365 Logger::log (LogLevel::Info, " Starting at: " + _config.nextKey .toString ());
367366 Logger::log (LogLevel::Info, " Ending at: " + _config.endKey .toString ());
368- Logger::log (LogLevel::Info, " Counting by: " + util::format ( _config.stride ));
367+ Logger::log (LogLevel::Info, " Counting by: " + _config.stride . toString ( ));
369368
370369 try {
371370
@@ -563,7 +562,19 @@ int main(int argc, char **argv)
563562 }
564563 optShares = true ;
565564 } else if (optArg.equals (" " , " --stride" )) {
566- _config.stride = util::parseUInt64 (optArg.arg );
565+ try {
566+ _config.stride = secp256k1::uint256 (optArg.arg );
567+ } catch (...) {
568+ throw std::string (" invalid argument: : expected hex string" );
569+ }
570+
571+ if (_config.stride .cmp (secp256k1::N) >= 0 ) {
572+ throw std::string (" argument is out of range" );
573+ }
574+
575+ if (_config.stride .cmp (0 ) == 0 ) {
576+ throw std::string (" argument is out of range" );
577+ }
567578 }
568579
569580 } catch (std::string err) {
0 commit comments