@@ -63,17 +63,17 @@ pub fn blocks(start_height: &str) {
63
63
/// GET /api/v1/blocks-bulk/:minHeight[/:maxHeight]
64
64
/// <https://mempool.space/docs/api/rest#get-blocks-bulk>
65
65
pub fn blocks_bulk ( min_height : & str , max_height : & str ) {
66
- //TODO blocks_tip_height
67
66
let min_height_int = min_height. parse :: < i32 > ( ) . unwrap_or ( 0 ) ;
68
67
let max_height_int = max_height. parse :: < i32 > ( ) . unwrap_or ( 0 ) ;
69
- if min_height_int >= 0 && max_height_int >= 0 && min_height_int <= max_height_int {
68
+ if min_height_int >= 0 && max_height_int >= 0 && min_height_int < max_height_int {
70
69
let _res = blocking ( & format ! ( "v1/blocks-bulk/{}/{}" , min_height, max_height) ) ;
71
70
} else if min_height_int >= 0 && max_height_int >= 0 && min_height_int >= max_height_int {
72
71
let _res = blocking ( & format ! ( "v1/blocks-bulk/{}/{}" , max_height, min_height) ) ;
73
72
} else {
74
- let blocks_tip_height = api ( "blocks_tip_height" , & "extraneous_arg" ) ;
73
+ let blocks_tip_height = api:: api ( "blocks_tip_height" , & "extraneous_arg" ) ;
75
74
let _res = blocking ( & format ! ( "v1/blocks-bulk/{}/{}" , min_height, blocks_tip_height) ) ;
76
75
}
76
+ print ! ( "This API is disabled. Set config.MEMPOOL.MAX_BLOCKS_BULK_QUERY to a positive number to enable it." ) ;
77
77
}
78
78
79
79
/// <https://mempool.space/docs/api/rest>
@@ -261,9 +261,11 @@ pub struct Args {
261
261
/// `https://mempool.space/api/v1/blocks/<BLOCKS_START_HEIGHT>`
262
262
pub blocks : Option < String > ,
263
263
264
- /// - V1 BLOCKS_BULK <BLOCK_HEIGHT_START > <BLOCK_HEIGHT_STOP >
265
- /// `https://mempool.space/api/v1/blocks-bulk/<BLOCK_HEIGHT_START >/<BLOCK_HEIGHT_STOP >`
264
+ /// - V1 BLOCKS_BULK <MAX_HEIGHT > <MIN_HEIGHT >
265
+ /// `https://mempool.space/api/v1/blocks-bulk/<MIN_HEIGHT >/<MAX_HEIGHT >`
266
266
pub blocks_bulk : Option < String > ,
267
+ pub min_height : Option < String > ,
268
+ pub max_height : Option < String > ,
267
269
268
270
/// Configuration file.
269
271
pub config : Option < PathBuf > ,
@@ -355,7 +357,10 @@ impl Args {
355
357
opts. optopt ( "" , "start_index" , "block txs api call" , "START_INDEX" ) ;
356
358
357
359
opts. optopt ( "" , "blocks" , "block txids api call" , "BLOCKS_START_HEIGHT" ) ;
358
- opts. optopt ( "" , "blocks_bulk" , "block txids api call" , "BLOCKS_BULK" ) ;
360
+
361
+ opts. optflag ( "" , "blocks_bulk" , "block txids api call" ) ;
362
+ opts. optopt ( "" , "min_height" , "block txids api call" , "MIN_HEIGHT" ) ;
363
+ opts. optopt ( "" , "max_height" , "block txids api call" , "MAX_HEIGHT" ) ;
359
364
360
365
//OPTOPT
361
366
opts. optopt ( "c" , "config" , "sets the configuration file" , "CONFIG" ) ;
@@ -500,6 +505,12 @@ impl Args {
500
505
blocks ( & arg_blocks. unwrap ( ) ) ;
501
506
std:: process:: exit ( 0 ) ;
502
507
}
508
+ if matches. opt_present ( "blocks_bulk" ) {
509
+ let arg_min_height = matches. opt_str ( "min_height" ) ; //expect a integer as string
510
+ let arg_max_height = matches. opt_str ( "max_height" ) ; //expect a integer as string
511
+ blocks_bulk ( & arg_min_height. unwrap ( ) , & arg_max_height. unwrap ( ) ) ;
512
+ std:: process:: exit ( 0 ) ;
513
+ }
503
514
504
515
if matches. opt_present ( "h" )
505
516
|| ( matches. free . is_empty ( )
@@ -606,6 +617,8 @@ impl Args {
606
617
// V1 BLOCKS_BULK
607
618
// https://mempool.space/api/v1/blocks-bulk/<BLOCK_HEIGHT_START>/<BLOCK_HEIGHT_STOP>"
608
619
blocks_bulk : matches. opt_str ( "blocks_bulk" ) ,
620
+ min_height : matches. opt_str ( "min_height" ) ,
621
+ max_height : matches. opt_str ( "max_height" ) ,
609
622
610
623
server : matches. opt_str ( "s" ) ,
611
624
auth : matches. opt_str ( "a" ) ,
0 commit comments