@@ -16,7 +16,6 @@ use std::cmp;
1616use std:: sync:: Arc ;
1717use std:: thread:: { self , JoinHandle } ;
1818use time:: now_ms;
19- use util:: RwLockUpgradableReadGuard ;
2019use verification:: { BlockVerifier , Verifier } ;
2120
2221pub struct ChainService < CI > {
@@ -136,7 +135,7 @@ impl<CI: ChainIndex + 'static> ChainService<CI> {
136135 let mut old_cumulative_blks = Vec :: new ( ) ;
137136 let mut new_cumulative_blks = Vec :: new ( ) ;
138137
139- let tip_header = self . shared . tip_header ( ) . upgradable_read ( ) ;
138+ let mut tip_header = self . shared . tip_header ( ) . write ( ) ;
140139 let tip_number = tip_header. number ( ) ;
141140 self . shared . store ( ) . save_with_batch ( |batch| {
142141 let root = self . check_transactions ( batch, block) ?;
@@ -180,7 +179,6 @@ impl<CI: ChainIndex + 'static> ChainService<CI> {
180179
181180 if new_best_block {
182181 debug ! ( target: "chain" , "update index" ) ;
183- let mut guard = RwLockUpgradableReadGuard :: upgrade ( tip_header) ;
184182 let new_tip_header =
185183 TipHeader :: new ( block. header ( ) . clone ( ) , total_difficulty, output_root) ;
186184 self . shared . store ( ) . save_with_batch ( |batch| {
@@ -197,7 +195,7 @@ impl<CI: ChainIndex + 'static> ChainService<CI> {
197195 self . shared . store ( ) . rebuild_tree ( output_root) ;
198196 Ok ( ( ) )
199197 } ) ?;
200- * guard = new_tip_header;
198+ * tip_header = new_tip_header;
201199 debug ! ( target: "chain" , "update index release" ) ;
202200 }
203201
0 commit comments