@@ -20,7 +20,7 @@ use std::time::Duration;
2020
2121use burnchains:: {
2222 db:: { BurnchainBlockData , BurnchainDB } ,
23- Burnchain , BurnchainBlockHeader , BurnchainHeaderHash , Error as BurnchainError ,
23+ Burnchain , BurnchainBlockHeader , BurnchainHeaderHash , Error as BurnchainError , Txid ,
2424} ;
2525use chainstate:: burn:: {
2626 db:: sortdb:: { PoxId , SortitionDB , SortitionId } ,
@@ -107,6 +107,7 @@ pub trait BlockEventDispatcher {
107107 metadata : StacksHeaderInfo ,
108108 receipts : Vec < StacksTransactionReceipt > ,
109109 parent : & StacksBlockId ,
110+ winner_txid : Txid ,
110111 ) ;
111112
112113 fn dispatch_boot_receipts ( & mut self , receipts : Vec < StacksTransactionReceipt > ) ;
@@ -572,15 +573,16 @@ impl<'a, T: BlockEventDispatcher, N: CoordinatorNotices, U: RewardSetProvider>
572573 & block_receipt. header . anchored_header . block_hash ( ) ,
573574 ) ?;
574575 if in_sortition_set {
575- let new_canonical_stacks_block = SortitionDB :: get_block_snapshot (
576+ let new_canonical_block_snapshot = SortitionDB :: get_block_snapshot (
576577 self . sortition_db . conn ( ) ,
577578 canonical_sortition_tip,
578579 ) ?
579580 . expect ( & format ! (
580581 "FAIL: could not find data for the canonical sortition {}" ,
581582 canonical_sortition_tip
582- ) )
583- . get_canonical_stacks_block_id ( ) ;
583+ ) ) ;
584+ let new_canonical_stacks_block =
585+ new_canonical_block_snapshot. get_canonical_stacks_block_id ( ) ;
584586 self . canonical_chain_tip = Some ( new_canonical_stacks_block) ;
585587 debug ! ( "Bump blocks processed" ) ;
586588 self . notifier . notify_stacks_block_processed ( ) ;
@@ -589,6 +591,15 @@ impl<'a, T: BlockEventDispatcher, N: CoordinatorNotices, U: RewardSetProvider>
589591
590592 if let Some ( dispatcher) = self . dispatcher {
591593 let metadata = & block_receipt. header ;
594+ let winner_txid = SortitionDB :: get_block_snapshot_for_winning_stacks_block (
595+ & self . sortition_db . index_conn ( ) ,
596+ canonical_sortition_tip,
597+ & block_hash,
598+ )
599+ . expect ( "FAIL: could not find block snapshot for winning block hash" )
600+ . expect ( "FAIL: could not find block snapshot for winning block hash" )
601+ . winning_block_txid ;
602+
592603 let block: StacksBlock = {
593604 let block_path = StacksChainState :: get_block_path (
594605 & self . chain_state_db . blocks_path ,
@@ -609,6 +620,7 @@ impl<'a, T: BlockEventDispatcher, N: CoordinatorNotices, U: RewardSetProvider>
609620 block_receipt. header ,
610621 block_receipt. tx_receipts ,
611622 & parent,
623+ winner_txid,
612624 ) ;
613625 }
614626
0 commit comments