File tree 4 files changed +21
-9
lines changed
4 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -184,11 +184,16 @@ impl BlockChain {
184
184
let new_header = new_block. header_view ( ) ;
185
185
let parent_hash_of_new_block = new_header. parent_hash ( ) ;
186
186
let parent_details_of_new_block = self . block_details ( & parent_hash_of_new_block) . expect ( "Invalid parent hash" ) ;
187
- let prev_best_proposal_hash = self . best_proposal_block_hash ( ) ;
187
+ let grandparent_hash_of_new_block = parent_details_of_new_block . parent ;
188
188
let prev_best_hash = self . best_block_hash ( ) ;
189
189
190
190
if parent_details_of_new_block. total_score + new_header. score ( ) > self . best_proposal_block_detail ( ) . total_score
191
- && engine. can_change_canon_chain ( & new_header, prev_best_hash, prev_best_proposal_hash)
191
+ && engine. can_change_canon_chain (
192
+ new_header. hash ( ) ,
193
+ parent_hash_of_new_block,
194
+ grandparent_hash_of_new_block,
195
+ prev_best_hash,
196
+ )
192
197
{
193
198
cinfo ! (
194
199
BLOCKCHAIN ,
Original file line number Diff line number Diff line change @@ -242,11 +242,16 @@ impl HeaderChain {
242
242
fn best_header_changed ( & self , new_header : & HeaderView , engine : & dyn CodeChainEngine ) -> BestHeaderChanged {
243
243
let parent_hash_of_new_header = new_header. parent_hash ( ) ;
244
244
let parent_details_of_new_header = self . block_details ( & parent_hash_of_new_header) . expect ( "Invalid parent hash" ) ;
245
- let prev_best_proposal_hash = self . best_proposal_header_hash ( ) ;
245
+ let grandparent_hash_of_new_header = parent_details_of_new_header . parent ;
246
246
let prev_best_hash = self . best_header_hash ( ) ;
247
247
let is_new_best = parent_details_of_new_header. total_score + new_header. score ( )
248
248
> self . best_proposal_header_detail ( ) . total_score
249
- && engine. can_change_canon_chain ( & new_header, prev_best_hash, prev_best_proposal_hash) ;
249
+ && engine. can_change_canon_chain (
250
+ new_header. hash ( ) ,
251
+ parent_hash_of_new_header,
252
+ grandparent_hash_of_new_header,
253
+ prev_best_hash,
254
+ ) ;
250
255
251
256
if is_new_best {
252
257
ctrace ! (
Original file line number Diff line number Diff line change @@ -271,9 +271,10 @@ pub trait ConsensusEngine: Sync + Send {
271
271
/// Only the descendant of the current best block could be the next best block in Tendermint consensus.
272
272
fn can_change_canon_chain (
273
273
& self ,
274
- _new_header : & HeaderView ,
274
+ _new_block_hash : H256 ,
275
+ _parent_hash_of_new_header : H256 ,
276
+ _grandparent_hash_of_new_header : H256 ,
275
277
_previous_best_hash : H256 ,
276
- _previous_best_proposal_hash : H256 ,
277
278
) -> bool {
278
279
true
279
280
}
Original file line number Diff line number Diff line change @@ -311,11 +311,12 @@ impl ConsensusEngine for Tendermint {
311
311
312
312
fn can_change_canon_chain (
313
313
& self ,
314
- new_header : & HeaderView ,
314
+ _new_header_hash : H256 ,
315
+ parent_hash_of_new_header : H256 ,
316
+ grandparent_hash_of_new_header : H256 ,
315
317
prev_best_hash : H256 ,
316
- prev_best_proposal_hash : H256 ,
317
318
) -> bool {
318
- new_header . parent_hash ( ) == prev_best_hash || new_header . parent_hash ( ) == prev_best_proposal_hash
319
+ parent_hash_of_new_header == prev_best_hash || grandparent_hash_of_new_header == prev_best_hash
319
320
}
320
321
321
322
fn action_handlers ( & self ) -> & [ Arc < dyn ActionHandler > ] {
You can’t perform that action at this time.
0 commit comments