@@ -150,8 +150,8 @@ pub struct Chain {
150150 store : Arc < store:: ChainStore > ,
151151 adapter : Arc < dyn ChainAdapter + Send + Sync > ,
152152 orphans : Arc < OrphanBlockPool > ,
153- txhashset : Arc < RwLock < txhashset :: TxHashSet > > ,
154- header_pmmr : Arc < RwLock < txhashset :: PMMRHandle < BlockHeader > > > ,
153+ txhashset : Arc < RwLock < TxHashSet > > ,
154+ header_pmmr : Arc < RwLock < PMMRHandle < BlockHeader > > > ,
155155 pibd_segmenter : Arc < RwLock < Option < Segmenter > > > ,
156156 pibd_desegmenter : Arc < RwLock < Option < Desegmenter > > > ,
157157 // POW verification function
@@ -189,9 +189,9 @@ impl Chain {
189189 // Initialize the output_pos index based on UTXO set
190190 // and NRD kernel_pos index based recent kernel history.
191191 {
192- let batch = store. batch ( ) ?;
193- txhashset. init_output_pos_index ( & header_pmmr, & batch) ?;
194- txhashset. init_recent_kernel_pos_index ( & header_pmmr, & batch) ?;
192+ let mut batch = store. batch ( ) ?;
193+ txhashset. init_output_pos_index ( & header_pmmr, & mut batch) ?;
194+ txhashset. init_recent_kernel_pos_index ( & header_pmmr, & mut batch) ?;
195195 batch. commit ( ) ?;
196196 }
197197
@@ -275,7 +275,7 @@ impl Chain {
275275 pub fn reset_chain_head_to_genesis ( & self ) -> Result < ( ) , Error > {
276276 let mut header_pmmr = self . header_pmmr . write ( ) ;
277277 let mut txhashset = self . txhashset . write ( ) ;
278- let batch = self . store . batch ( ) ?;
278+ let mut batch = self . store . batch ( ) ?;
279279
280280 // Change head back to genesis
281281 {
@@ -314,7 +314,7 @@ impl Chain {
314314
315315 /// Reset PIBD head
316316 pub fn reset_pibd_head ( & self ) -> Result < ( ) , Error > {
317- let batch = self . store . batch ( ) ?;
317+ let mut batch = self . store . batch ( ) ?;
318318 batch. save_pibd_head ( & self . genesis ( ) . into ( ) ) ?;
319319 Ok ( ( ) )
320320 }
@@ -530,9 +530,9 @@ impl Chain {
530530 pub fn new_ctx < ' a > (
531531 & self ,
532532 opts : Options ,
533- batch : store :: Batch < ' a > ,
534- header_pmmr : & ' a mut txhashset :: PMMRHandle < BlockHeader > ,
535- txhashset : & ' a mut txhashset :: TxHashSet ,
533+ batch : Batch < ' a > ,
534+ header_pmmr : & ' a mut PMMRHandle < BlockHeader > ,
535+ txhashset : & ' a mut TxHashSet ,
536536 ) -> Result < pipe:: BlockContext < ' a > , Error > {
537537 let denylist = self . denylist . read ( ) . clone ( ) ;
538538 Ok ( pipe:: BlockContext {
@@ -832,7 +832,7 @@ impl Chain {
832832 & self ,
833833 header : & BlockHeader ,
834834 ext : & mut ExtensionPair ,
835- batch : & Batch ,
835+ batch : & mut Batch ,
836836 ) -> Result < BlockHeader , Error > {
837837 let denylist = self . denylist . read ( ) . clone ( ) ;
838838 pipe:: rewind_and_apply_fork ( header, ext, batch, & |header| {
@@ -846,7 +846,7 @@ impl Chain {
846846 & self ,
847847 header : & BlockHeader ,
848848 ext : & mut HeaderExtension ,
849- batch : & Batch ,
849+ batch : & mut Batch ,
850850 ) -> Result < ( ) , Error > {
851851 let denylist = self . denylist . read ( ) . clone ( ) ;
852852 pipe:: rewind_and_apply_header_fork ( header, ext, batch, & |header| {
@@ -1015,7 +1015,7 @@ impl Chain {
10151015 fn validate_kernel_history (
10161016 & self ,
10171017 header : & BlockHeader ,
1018- txhashset : & txhashset :: TxHashSet ,
1018+ txhashset : & TxHashSet ,
10191019 ) -> Result < ( ) , Error > {
10201020 debug ! ( "validate_kernel_history: rewinding and validating kernel history (readonly)" ) ;
10211021
@@ -1151,11 +1151,11 @@ impl Chain {
11511151 self . validate_kernel_history ( & header, & txhashset) ?;
11521152
11531153 let header_pmmr = self . header_pmmr . read ( ) ;
1154- let batch = self . store . batch ( ) ?;
1154+ let mut batch = self . store . batch ( ) ?;
11551155 txhashset. verify_kernel_pos_index (
11561156 & self . genesis . header ,
11571157 & header_pmmr,
1158- & batch,
1158+ & mut batch,
11591159 None ,
11601160 None ,
11611161 ) ?;
@@ -1213,10 +1213,10 @@ impl Chain {
12131213 }
12141214
12151215 // Rebuild our output_pos index in the db based on fresh UTXO set.
1216- txhashset. init_output_pos_index ( & header_pmmr, & batch) ?;
1216+ txhashset. init_output_pos_index ( & header_pmmr, & mut batch) ?;
12171217
12181218 // Rebuild our NRD kernel_pos index based on recent kernel history.
1219- txhashset. init_recent_kernel_pos_index ( & header_pmmr, & batch) ?;
1219+ txhashset. init_recent_kernel_pos_index ( & header_pmmr, & mut batch) ?;
12201220
12211221 // Commit all the changes to the db.
12221222 batch. commit ( ) ?;
@@ -1257,9 +1257,9 @@ impl Chain {
12571257 /// *Only* runs if we are not in archive mode.
12581258 fn remove_historical_blocks (
12591259 & self ,
1260- header_pmmr : & txhashset :: PMMRHandle < BlockHeader > ,
1260+ header_pmmr : & PMMRHandle < BlockHeader > ,
12611261 archive_header : BlockHeader ,
1262- batch : & store :: Batch < ' _ > ,
1262+ batch : & mut Batch < ' _ > ,
12631263 ) -> Result < ( ) , Error > {
12641264 if self . archive_mode ( ) {
12651265 return Ok ( ( ) ) ;
@@ -1345,7 +1345,7 @@ impl Chain {
13451345 // Take a write lock on the txhashet and start a new writeable db batch.
13461346 let header_pmmr = self . header_pmmr . read ( ) ;
13471347 let mut txhashset = self . txhashset . write ( ) ;
1348- let batch = self . store . batch ( ) ?;
1348+ let mut batch = self . store . batch ( ) ?;
13491349
13501350 // Compact the txhashset itself (rewriting the pruned backend files).
13511351 {
@@ -1361,15 +1361,15 @@ impl Chain {
13611361
13621362 // If we are not in archival mode remove historical blocks from the db.
13631363 if !self . archive_mode ( ) {
1364- self . remove_historical_blocks ( & header_pmmr, archive_header, & batch) ?;
1364+ self . remove_historical_blocks ( & header_pmmr, archive_header, & mut batch) ?;
13651365 }
13661366
13671367 // Make sure our output_pos index is consistent with the UTXO set.
1368- txhashset. init_output_pos_index ( & header_pmmr, & batch) ?;
1368+ txhashset. init_output_pos_index ( & header_pmmr, & mut batch) ?;
13691369
13701370 // TODO - Why is this part of chain compaction?
13711371 // Rebuild our NRD kernel_pos index based on recent kernel history.
1372- txhashset. init_recent_kernel_pos_index ( & header_pmmr, & batch) ?;
1372+ txhashset. init_recent_kernel_pos_index ( & header_pmmr, & mut batch) ?;
13731373
13741374 // Commit all the above db changes.
13751375 batch. commit ( ) ?;
@@ -1439,7 +1439,8 @@ impl Chain {
14391439 0
14401440 } else {
14411441 self . get_header_by_height ( start_block_height - 1 ) ?
1442- . output_mmr_size + 1
1442+ . output_mmr_size
1443+ + 1
14431444 } ;
14441445 let end_mmr_size = self . get_header_by_height ( end_block_height) ?. output_mmr_size ;
14451446 Ok ( ( start_mmr_size, end_mmr_size) )
0 commit comments