11use std:: collections:: HashMap ;
22
3- use bitcoin:: { BlockHash , Network , Target , Transaction , Txid , Weight } ;
3+ use bitcoin:: { BlockHash , Transaction , Txid , Weight } ;
44use bitcoin_jsonrpsee:: client:: { BlockTemplateTransaction , RawMempoolTxFees } ;
55use hashlink:: { LinkedHashMap , LinkedHashSet } ;
66use imbl:: { OrdMap , OrdSet , ordmap} ;
@@ -482,23 +482,21 @@ fn saturating_sub_weight(lhs: Weight, rhs: Weight) -> Weight {
482482pub struct Mempool {
483483 by_ancestor_fee_rate : ByAncestorFeeRate ,
484484 chain : Chain ,
485- network : Network ,
486485 /// Map of txs (which may not be in the mempool) to their direct child txs,
487486 /// which MUST be in the mempool
488487 tx_childs : TxChilds ,
489488 txs : MempoolTxs ,
490489}
491490
492491impl Mempool {
493- fn new ( network : Network , prev_blockhash : BlockHash ) -> Self {
492+ fn new ( prev_blockhash : BlockHash ) -> Self {
494493 let chain = Chain {
495494 tip : prev_blockhash,
496495 blocks : imbl:: HashMap :: new ( ) ,
497496 } ;
498497 Self {
499498 by_ancestor_fee_rate : ByAncestorFeeRate :: default ( ) ,
500499 chain,
501- network,
502500 tx_childs : TxChilds :: default ( ) ,
503501 txs : MempoolTxs :: default ( ) ,
504502 }
@@ -508,34 +506,6 @@ impl Mempool {
508506 & self . chain . blocks [ & self . chain . tip ]
509507 }
510508
511- /// Next target, if known
512- pub fn next_target ( & self ) -> Option < Target > {
513- let tip = self . tip ( ) ;
514- let next_height = tip. height + 1 ;
515- let network_params = self . network . params ( ) ;
516- if !network_params. no_pow_retargeting
517- && next_height % network_params. miner_confirmation_window == 0
518- {
519- if let Some ( first_block_in_period) = self
520- . chain
521- . iter ( )
522- . nth ( network_params. miner_confirmation_window as usize - 1 )
523- {
524- let spacing = tip. time - first_block_in_period. time ;
525- let res = bitcoin:: CompactTarget :: from_next_work_required (
526- tip. compact_target ,
527- spacing as u64 ,
528- network_params,
529- ) ;
530- Some ( res. into ( ) )
531- } else {
532- None
533- }
534- } else {
535- Some ( tip. compact_target . into ( ) )
536- }
537- }
538-
539509 /// Insert a tx into the mempool,
540510 /// stating conflicts with other txs due to reasons other than shared
541511 /// inputs.
@@ -979,7 +949,7 @@ impl Mempool {
979949mod tests {
980950 use super :: * ;
981951 use bitcoin:: {
982- Amount , Network , OutPoint , ScriptBuf , Sequence , TxIn , TxOut , Witness ,
952+ Amount , OutPoint , ScriptBuf , Sequence , TxIn , TxOut , Witness ,
983953 absolute:: LockTime , hashes:: Hash as _, transaction:: Version ,
984954 } ;
985955
@@ -1006,7 +976,7 @@ mod tests {
1006976 }
1007977
1008978 fn test_mempool ( ) -> Mempool {
1009- Mempool :: new ( Network :: Regtest , BlockHash :: all_zeros ( ) )
979+ Mempool :: new ( BlockHash :: all_zeros ( ) )
1010980 }
1011981
1012982 /// Reproduces the prod crash: inserting a tx whose `conflicts_with`
0 commit comments