@@ -10,6 +10,8 @@ pub struct Settings {
10
10
bitcoin_rpc_username : Option < String > ,
11
11
chain : Option < Chain > ,
12
12
commit_interval : Option < usize > ,
13
+ savepoint_interval : Option < usize > ,
14
+ max_savepoints : Option < usize > ,
13
15
config : Option < PathBuf > ,
14
16
config_dir : Option < PathBuf > ,
15
17
cookie_file : Option < PathBuf > ,
@@ -115,6 +117,8 @@ impl Settings {
115
117
bitcoin_rpc_username : self . bitcoin_rpc_username . or ( source. bitcoin_rpc_username ) ,
116
118
chain : self . chain . or ( source. chain ) ,
117
119
commit_interval : self . commit_interval . or ( source. commit_interval ) ,
120
+ savepoint_interval : self . savepoint_interval . or ( source. savepoint_interval ) ,
121
+ max_savepoints : self . max_savepoints . or ( source. max_savepoints ) ,
118
122
config : self . config . or ( source. config ) ,
119
123
config_dir : self . config_dir . or ( source. config_dir ) ,
120
124
cookie_file : self . cookie_file . or ( source. cookie_file ) ,
@@ -159,6 +163,8 @@ impl Settings {
159
163
. or ( options. testnet4 . then_some ( Chain :: Testnet4 ) )
160
164
. or ( options. chain_argument ) ,
161
165
commit_interval : options. commit_interval ,
166
+ savepoint_interval : options. savepoint_interval ,
167
+ max_savepoints : options. max_savepoints ,
162
168
config : options. config ,
163
169
config_dir : options. config_dir ,
164
170
cookie_file : options. cookie_file ,
@@ -247,6 +253,8 @@ impl Settings {
247
253
bitcoin_rpc_username : get_string ( "BITCOIN_RPC_USERNAME" ) ,
248
254
chain : get_chain ( "CHAIN" ) ?,
249
255
commit_interval : get_usize ( "COMMIT_INTERVAL" ) ?,
256
+ savepoint_interval : get_usize ( "SAVEPOINT_INTERVAL" ) ?,
257
+ max_savepoints : get_usize ( "MAX_SAVEPOINTS" ) ?,
250
258
config : get_path ( "CONFIG" ) ,
251
259
config_dir : get_path ( "CONFIG_DIR" ) ,
252
260
cookie_file : get_path ( "COOKIE_FILE" ) ,
@@ -277,6 +285,8 @@ impl Settings {
277
285
bitcoin_rpc_limit : None ,
278
286
chain : Some ( Chain :: Regtest ) ,
279
287
commit_interval : None ,
288
+ savepoint_interval : None ,
289
+ max_savepoints : None ,
280
290
config : None ,
281
291
config_dir : None ,
282
292
cookie_file : None ,
@@ -344,6 +354,8 @@ impl Settings {
344
354
bitcoin_rpc_username : self . bitcoin_rpc_username ,
345
355
chain : Some ( chain) ,
346
356
commit_interval : Some ( self . commit_interval . unwrap_or ( 5000 ) ) ,
357
+ savepoint_interval : Some ( self . savepoint_interval . unwrap_or ( 10 ) ) ,
358
+ max_savepoints : Some ( self . max_savepoints . unwrap_or ( 2 ) ) ,
347
359
config : None ,
348
360
config_dir : None ,
349
361
cookie_file : Some ( cookie_file) ,
@@ -470,6 +482,14 @@ impl Settings {
470
482
self . commit_interval . unwrap ( )
471
483
}
472
484
485
+ pub fn savepoint_interval ( & self ) -> usize {
486
+ self . savepoint_interval . unwrap ( )
487
+ }
488
+
489
+ pub fn max_savepoints ( & self ) -> usize {
490
+ self . max_savepoints . unwrap ( )
491
+ }
492
+
473
493
pub fn cookie_file ( & self ) -> Result < PathBuf > {
474
494
if let Some ( cookie_file) = & self . cookie_file {
475
495
return Ok ( cookie_file. clone ( ) ) ;
@@ -933,6 +953,20 @@ mod tests {
933
953
assert_eq ! ( arguments. options. commit_interval, Some ( 500 ) ) ;
934
954
}
935
955
956
+ #[ test]
957
+ fn setting_savepoint_interval ( ) {
958
+ let arguments =
959
+ Arguments :: try_parse_from ( [ "ord" , "--savepoint-interval" , "500" , "index" , "update" ] ) . unwrap ( ) ;
960
+ assert_eq ! ( arguments. options. savepoint_interval, Some ( 500 ) ) ;
961
+ }
962
+
963
+ #[ test]
964
+ fn setting_max_savepoints ( ) {
965
+ let arguments =
966
+ Arguments :: try_parse_from ( [ "ord" , "--max-savepoints" , "10" , "index" , "update" ] ) . unwrap ( ) ;
967
+ assert_eq ! ( arguments. options. max_savepoints, Some ( 10 ) ) ;
968
+ }
969
+
936
970
#[ test]
937
971
fn index_runes ( ) {
938
972
assert ! ( parse( & [ "--chain=signet" , "--index-runes" ] ) . index_runes_raw( ) ) ;
@@ -1032,6 +1066,8 @@ mod tests {
1032
1066
( "BITCOIN_RPC_USERNAME" , "bitcoin username" ) ,
1033
1067
( "CHAIN" , "signet" ) ,
1034
1068
( "COMMIT_INTERVAL" , "1" ) ,
1069
+ ( "SAVEPOINT_INTERVAL" , "10" ) ,
1070
+ ( "MAX_SAVEPOINTS" , "2" ) ,
1035
1071
( "CONFIG" , "config" ) ,
1036
1072
( "CONFIG_DIR" , "config dir" ) ,
1037
1073
( "COOKIE_FILE" , "cookie file" ) ,
@@ -1065,6 +1101,8 @@ mod tests {
1065
1101
bitcoin_rpc_username: Some ( "bitcoin username" . into( ) ) ,
1066
1102
chain: Some ( Chain :: Signet ) ,
1067
1103
commit_interval: Some ( 1 ) ,
1104
+ savepoint_interval: Some ( 10 ) ,
1105
+ max_savepoints: Some ( 2 ) ,
1068
1106
config: Some ( "config" . into( ) ) ,
1069
1107
config_dir: Some ( "config dir" . into( ) ) ,
1070
1108
cookie_file: Some ( "cookie file" . into( ) ) ,
@@ -1111,6 +1149,8 @@ mod tests {
1111
1149
"--bitcoin-rpc-username=bitcoin username" ,
1112
1150
"--chain=signet" ,
1113
1151
"--commit-interval=1" ,
1152
+ "--savepoint-interval=10" ,
1153
+ "--max-savepoints=2" ,
1114
1154
"--config=config" ,
1115
1155
"--config-dir=config dir" ,
1116
1156
"--cookie-file=cookie file" ,
@@ -1137,6 +1177,8 @@ mod tests {
1137
1177
bitcoin_rpc_username: Some ( "bitcoin username" . into( ) ) ,
1138
1178
chain: Some ( Chain :: Signet ) ,
1139
1179
commit_interval: Some ( 1 ) ,
1180
+ savepoint_interval: Some ( 10 ) ,
1181
+ max_savepoints: Some ( 2 ) ,
1140
1182
config: Some ( "config" . into( ) ) ,
1141
1183
config_dir: Some ( "config dir" . into( ) ) ,
1142
1184
cookie_file: Some ( "cookie file" . into( ) ) ,
0 commit comments