File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -172,6 +172,10 @@ where
172172 ( * * self ) . server_features ( )
173173 }
174174
175+ fn mempool_get_info ( & self ) -> Result < MempoolInfoRes , Error > {
176+ ( * * self ) . mempool_get_info ( )
177+ }
178+
175179 fn ping ( & self ) -> Result < ( ) , Error > {
176180 ( * * self ) . ping ( )
177181 }
@@ -398,6 +402,12 @@ pub trait ElectrumApi {
398402 /// Returns the capabilities of the server.
399403 fn server_features ( & self ) -> Result < ServerFeaturesRes , Error > ;
400404
405+ /// Returns information about the current state of the mempool.
406+ ///
407+ /// This method was added in protocol v1.6 and replaces `relay_fee` by providing
408+ /// `minrelaytxfee` along with additional mempool fee information.
409+ fn mempool_get_info ( & self ) -> Result < MempoolInfoRes , Error > ;
410+
401411 /// Pings the server. This method can also be used as a "dummy" call to trigger the processing
402412 /// of incoming block header or script notifications.
403413 fn ping ( & self ) -> Result < ( ) , Error > ;
@@ -607,6 +617,10 @@ mod test {
607617 unreachable ! ( )
608618 }
609619
620+ fn mempool_get_info ( & self ) -> Result < super :: MempoolInfoRes , super :: Error > {
621+ unreachable ! ( )
622+ }
623+
610624 fn ping ( & self ) -> Result < ( ) , super :: Error > {
611625 unreachable ! ( )
612626 }
Original file line number Diff line number Diff line change @@ -362,6 +362,11 @@ impl ElectrumApi for Client {
362362 impl_inner_call ! ( self , server_features)
363363 }
364364
365+ #[ inline]
366+ fn mempool_get_info ( & self ) -> Result < MempoolInfoRes , Error > {
367+ impl_inner_call ! ( self , mempool_get_info)
368+ }
369+
365370 #[ inline]
366371 fn ping ( & self ) -> Result < ( ) , Error > {
367372 impl_inner_call ! ( self , ping)
Original file line number Diff line number Diff line change @@ -1179,6 +1179,17 @@ impl<T: Read + Write> ElectrumApi for RawClient<T> {
11791179 Ok ( serde_json:: from_value ( result) ?)
11801180 }
11811181
1182+ fn mempool_get_info ( & self ) -> Result < MempoolInfoRes , Error > {
1183+ let req = Request :: new_id (
1184+ self . last_id . fetch_add ( 1 , Ordering :: SeqCst ) ,
1185+ "mempool.get_info" ,
1186+ vec ! [ ] ,
1187+ ) ;
1188+ let result = self . call ( req) ?;
1189+
1190+ Ok ( serde_json:: from_value ( result) ?)
1191+ }
1192+
11821193 fn ping ( & self ) -> Result < ( ) , Error > {
11831194 let req = Request :: new_id (
11841195 self . last_id . fetch_add ( 1 , Ordering :: SeqCst ) ,
@@ -1227,6 +1238,16 @@ mod test {
12271238 assert_eq ! ( resp. pruning, None ) ;
12281239 }
12291240
1241+ #[ test]
1242+ fn test_mempool_get_info ( ) {
1243+ let client = get_test_client ( ) ;
1244+
1245+ let resp = client. mempool_get_info ( ) . unwrap ( ) ;
1246+ assert ! ( resp. mempoolminfee >= 0.0 ) ;
1247+ assert ! ( resp. minrelaytxfee >= 0.0 ) ;
1248+ assert ! ( resp. incrementalrelayfee >= 0.0 ) ;
1249+ }
1250+
12301251 #[ test]
12311252 #[ ignore = "depends on a live server" ]
12321253 fn test_batch_response_ordering ( ) {
Original file line number Diff line number Diff line change @@ -202,6 +202,21 @@ pub struct ServerFeaturesRes {
202202 pub pruning : Option < i64 > ,
203203}
204204
205+ /// Response to a [`mempool_get_info`](../client/struct.Client.html#method.mempool_get_info) request.
206+ ///
207+ /// Contains information about the current state of the mempool.
208+ #[ derive( Clone , Debug , Deserialize ) ]
209+ pub struct MempoolInfoRes {
210+ /// Dynamic minimum fee rate in BTC/kvB for tx to be accepted given current conditions.
211+ /// The maximum of `minrelaytxfee` and minimum mempool fee.
212+ pub mempoolminfee : f64 ,
213+ /// Static operator-configurable minimum relay fee for transactions, in BTC/kvB.
214+ pub minrelaytxfee : f64 ,
215+ /// Static operator-configurable minimum fee rate increment for mempool limiting or
216+ /// replacement, in BTC/kvB.
217+ pub incrementalrelayfee : f64 ,
218+ }
219+
205220/// Response to a [`server_features`](../client/struct.Client.html#method.server_features) request.
206221#[ derive( Clone , Debug , Deserialize ) ]
207222pub struct GetHeadersRes {
You can’t perform that action at this time.
0 commit comments