@@ -53,14 +53,14 @@ void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& opti
53
53
}
54
54
55
55
const auto value{arg.substr (found + 1 )};
56
- int32_t height;
57
- if (!ParseInt32 (value, & height) || height < 0 || height >= std::numeric_limits<int >::max ()) {
56
+ const auto height{ToIntegral< int32_t >(value)} ;
57
+ if (!height || * height < 0 || * height >= std::numeric_limits<int >::max ()) {
58
58
throw std::runtime_error (strprintf (" Invalid height value (%s) for -testactivationheight=name@height." , arg));
59
59
}
60
60
61
61
const auto deployment_name{arg.substr (0 , found)};
62
62
if (const auto buried_deployment = GetBuriedDeployment (deployment_name)) {
63
- options.activation_heights [*buried_deployment] = height;
63
+ options.activation_heights [*buried_deployment] = * height;
64
64
} else {
65
65
throw std::runtime_error (strprintf (" Invalid name (%s) for -testactivationheight=name@height." , arg));
66
66
}
@@ -72,16 +72,22 @@ void ReadRegTestArgs(const ArgsManager& args, CChainParams::RegTestOptions& opti
72
72
throw std::runtime_error (" Version bits parameters malformed, expecting deployment:start:end[:min_activation_height]" );
73
73
}
74
74
CChainParams::VersionBitsParameters vbparams{};
75
- if (!ParseInt64 (vDeploymentParams[1 ], &vbparams.start_time )) {
75
+ const auto start_time{ToIntegral<int64_t >(vDeploymentParams[1 ])};
76
+ if (!start_time) {
76
77
throw std::runtime_error (strprintf (" Invalid nStartTime (%s)" , vDeploymentParams[1 ]));
77
78
}
78
- if (!ParseInt64 (vDeploymentParams[2 ], &vbparams.timeout )) {
79
+ vbparams.start_time = *start_time;
80
+ const auto timeout{ToIntegral<int64_t >(vDeploymentParams[2 ])};
81
+ if (!timeout) {
79
82
throw std::runtime_error (strprintf (" Invalid nTimeout (%s)" , vDeploymentParams[2 ]));
80
83
}
84
+ vbparams.timeout = *timeout;
81
85
if (vDeploymentParams.size () >= 4 ) {
82
- if (!ParseInt32 (vDeploymentParams[3 ], &vbparams.min_activation_height )) {
86
+ const auto min_activation_height{ToIntegral<int64_t >(vDeploymentParams[3 ])};
87
+ if (!min_activation_height) {
83
88
throw std::runtime_error (strprintf (" Invalid min_activation_height (%s)" , vDeploymentParams[3 ]));
84
89
}
90
+ vbparams.min_activation_height = *min_activation_height;
85
91
} else {
86
92
vbparams.min_activation_height = 0 ;
87
93
}
0 commit comments