@@ -3883,34 +3883,21 @@ impl SortitionDB {
3883
3883
. unwrap_or ( & burnchain. first_block_hash )
3884
3884
. clone ( ) ;
3885
3885
3886
- let rc = burnchain
3887
- . block_height_to_reward_cycle ( chain_tip. block_height )
3888
- . expect ( "FATAL: block height does not have a reward cycle" ) ;
3889
-
3890
- let rc_height = burnchain. reward_cycle_to_block_height ( rc) ;
3891
- let rc_consensus_hash = SortitionDB :: get_ancestor_snapshot (
3892
- conn,
3893
- cmp:: min ( chain_tip. block_height , rc_height) ,
3894
- & chain_tip. sortition_id ,
3895
- ) ?
3896
- . map ( |sn| sn. consensus_hash )
3897
- . ok_or ( db_error:: NotFoundError ) ?;
3898
-
3899
3886
test_debug ! (
3900
3887
"Chain view: {},{}-{},{},{}" ,
3901
3888
chain_tip. block_height,
3902
3889
chain_tip. burn_header_hash,
3903
3890
stable_block_height,
3904
3891
& burn_stable_block_hash,
3905
- & rc_consensus_hash ,
3892
+ & chain_tip . canonical_stacks_tip_consensus_hash ,
3906
3893
) ;
3907
3894
Ok ( BurnchainView {
3908
3895
burn_block_height : chain_tip. block_height ,
3909
3896
burn_block_hash : chain_tip. burn_header_hash ,
3910
3897
burn_stable_block_height : stable_block_height,
3911
3898
burn_stable_block_hash : burn_stable_block_hash,
3912
3899
last_burn_block_hashes : last_burn_block_hashes,
3913
- rc_consensus_hash,
3900
+ rc_consensus_hash : chain_tip . canonical_stacks_tip_consensus_hash ,
3914
3901
} )
3915
3902
}
3916
3903
}
@@ -4099,6 +4086,21 @@ impl SortitionDB {
4099
4086
Ok ( ( consensus_hash, stacks_block_hash) )
4100
4087
}
4101
4088
4089
+ #[ cfg( test) ]
4090
+ pub fn set_canonical_stacks_chain_tip (
4091
+ conn : & Connection ,
4092
+ ch : & ConsensusHash ,
4093
+ bhh : & BlockHeaderHash ,
4094
+ height : u64 ,
4095
+ ) -> Result < ( ) , db_error > {
4096
+ let tip = SortitionDB :: get_canonical_burn_chain_tip ( conn) ?;
4097
+ let args: & [ & dyn ToSql ] = & [ ch, bhh, & u64_to_sql ( height) ?, & tip. sortition_id ] ;
4098
+ conn. execute ( "UPDATE snapshots SET canonical_stacks_tip_consensus_hash = ?1, canonical_stacks_tip_hash = ?2, canonical_stacks_tip_height = ?3
4099
+ WHERE sortition_id = ?4" , args)
4100
+ . map_err ( db_error:: SqliteError ) ?;
4101
+ Ok ( ( ) )
4102
+ }
4103
+
4102
4104
/// Get the maximum arrival index for any known snapshot.
4103
4105
fn get_max_arrival_index ( conn : & Connection ) -> Result < u64 , db_error > {
4104
4106
match conn
0 commit comments