@@ -4,6 +4,7 @@ use {super::*, bitcoincore_rpc::Auth};
4
4
#[ serde( default , deny_unknown_fields) ]
5
5
pub struct Settings {
6
6
bitcoin_data_dir : Option < PathBuf > ,
7
+ bitcoin_rpc_limit : Option < u32 > ,
7
8
bitcoin_rpc_password : Option < String > ,
8
9
bitcoin_rpc_url : Option < String > ,
9
10
bitcoin_rpc_username : Option < String > ,
@@ -108,6 +109,7 @@ impl Settings {
108
109
pub ( crate ) fn or ( self , source : Settings ) -> Self {
109
110
Self {
110
111
bitcoin_data_dir : self . bitcoin_data_dir . or ( source. bitcoin_data_dir ) ,
112
+ bitcoin_rpc_limit : self . bitcoin_rpc_limit . or ( source. bitcoin_rpc_limit ) ,
111
113
bitcoin_rpc_password : self . bitcoin_rpc_password . or ( source. bitcoin_rpc_password ) ,
112
114
bitcoin_rpc_url : self . bitcoin_rpc_url . or ( source. bitcoin_rpc_url ) ,
113
115
bitcoin_rpc_username : self . bitcoin_rpc_username . or ( source. bitcoin_rpc_username ) ,
@@ -147,6 +149,7 @@ impl Settings {
147
149
pub ( crate ) fn from_options ( options : Options ) -> Self {
148
150
Self {
149
151
bitcoin_data_dir : options. bitcoin_data_dir ,
152
+ bitcoin_rpc_limit : options. bitcoin_rpc_limit ,
150
153
bitcoin_rpc_password : options. bitcoin_rpc_password ,
151
154
bitcoin_rpc_url : options. bitcoin_rpc_url ,
152
155
bitcoin_rpc_username : options. bitcoin_rpc_username ,
@@ -230,6 +233,7 @@ impl Settings {
230
233
231
234
Ok ( Self {
232
235
bitcoin_data_dir : get_path ( "BITCOIN_DATA_DIR" ) ,
236
+ bitcoin_rpc_limit : get_u32 ( "BITCOIN_RPC_LIMIT" ) ?,
233
237
bitcoin_rpc_password : get_string ( "BITCOIN_RPC_PASSWORD" ) ,
234
238
bitcoin_rpc_url : get_string ( "BITCOIN_RPC_URL" ) ,
235
239
bitcoin_rpc_username : get_string ( "BITCOIN_RPC_USERNAME" ) ,
@@ -262,6 +266,7 @@ impl Settings {
262
266
bitcoin_rpc_password : None ,
263
267
bitcoin_rpc_url : Some ( rpc_url. into ( ) ) ,
264
268
bitcoin_rpc_username : None ,
269
+ bitcoin_rpc_limit : None ,
265
270
chain : Some ( Chain :: Regtest ) ,
266
271
commit_interval : None ,
267
272
config : None ,
@@ -320,6 +325,7 @@ impl Settings {
320
325
321
326
Ok ( Self {
322
327
bitcoin_data_dir : Some ( bitcoin_data_dir) ,
328
+ bitcoin_rpc_limit : Some ( self . bitcoin_rpc_limit . unwrap_or ( 12 ) ) ,
323
329
bitcoin_rpc_password : self . bitcoin_rpc_password ,
324
330
bitcoin_rpc_url : Some (
325
331
self
@@ -550,6 +556,10 @@ impl Settings {
550
556
}
551
557
}
552
558
559
+ pub ( crate ) fn bitcoin_rpc_limit ( & self ) -> u32 {
560
+ self . bitcoin_rpc_limit . unwrap ( )
561
+ }
562
+
553
563
pub ( crate ) fn server_url ( & self ) -> Option < & str > {
554
564
self . server_url . as_deref ( )
555
565
}
@@ -978,6 +988,7 @@ mod tests {
978
988
fn from_env ( ) {
979
989
let env = vec ! [
980
990
( "BITCOIN_DATA_DIR" , "/bitcoin/data/dir" ) ,
991
+ ( "BITCOIN_RPC_LIMIT" , "12" ) ,
981
992
( "BITCOIN_RPC_PASSWORD" , "bitcoin password" ) ,
982
993
( "BITCOIN_RPC_URL" , "url" ) ,
983
994
( "BITCOIN_RPC_USERNAME" , "bitcoin username" ) ,
@@ -1010,6 +1021,7 @@ mod tests {
1010
1021
Settings :: from_env( env) . unwrap( ) ,
1011
1022
Settings {
1012
1023
bitcoin_data_dir: Some ( "/bitcoin/data/dir" . into( ) ) ,
1024
+ bitcoin_rpc_limit: Some ( 12 ) ,
1013
1025
bitcoin_rpc_password: Some ( "bitcoin password" . into( ) ) ,
1014
1026
bitcoin_rpc_url: Some ( "url" . into( ) ) ,
1015
1027
bitcoin_rpc_username: Some ( "bitcoin username" . into( ) ) ,
@@ -1055,6 +1067,7 @@ mod tests {
1055
1067
Options :: try_parse_from( [
1056
1068
"ord" ,
1057
1069
"--bitcoin-data-dir=/bitcoin/data/dir" ,
1070
+ "--bitcoin-rpc-limit=12" ,
1058
1071
"--bitcoin-rpc-password=bitcoin password" ,
1059
1072
"--bitcoin-rpc-url=url" ,
1060
1073
"--bitcoin-rpc-username=bitcoin username" ,
@@ -1081,6 +1094,7 @@ mod tests {
1081
1094
) ,
1082
1095
Settings {
1083
1096
bitcoin_data_dir: Some ( "/bitcoin/data/dir" . into( ) ) ,
1097
+ bitcoin_rpc_limit: Some ( 12 ) ,
1084
1098
bitcoin_rpc_password: Some ( "bitcoin password" . into( ) ) ,
1085
1099
bitcoin_rpc_url: Some ( "url" . into( ) ) ,
1086
1100
bitcoin_rpc_username: Some ( "bitcoin username" . into( ) ) ,
0 commit comments