@@ -665,12 +665,15 @@ impl Signer {
665
665
666
666
/// The actual `send_block_response` implementation. Declared so that we do
667
667
/// not need to duplicate in testing.
668
- fn impl_send_block_response ( & mut self , block_response : BlockResponse ) {
668
+ fn impl_send_block_response (
669
+ & mut self ,
670
+ block : Option < & NakamotoBlock > ,
671
+ block_response : BlockResponse ,
672
+ ) {
669
673
info ! (
670
674
"{self}: Broadcasting a block response to stacks node: {block_response:?}" ;
671
675
) ;
672
676
let accepted = matches ! ( block_response, BlockResponse :: Accepted ( ..) ) ;
673
- let block_hash = block_response. get_signer_signature_hash ( ) ;
674
677
match self
675
678
. stackerdb
676
679
. send_message_with_retry :: < SignerMessage > ( block_response. into ( ) )
@@ -683,8 +686,8 @@ impl Signer {
683
686
) ;
684
687
}
685
688
crate :: monitoring:: actions:: increment_block_responses_sent ( accepted) ;
686
- if let Ok ( Some ( block_info ) ) = self . signer_db . block_lookup ( & block_hash ) {
687
- crate :: monitoring:: actions:: record_block_response_latency ( & block_info . block ) ;
689
+ if let Some ( block ) = block {
690
+ crate :: monitoring:: actions:: record_block_response_latency ( block) ;
688
691
}
689
692
}
690
693
Err ( e) => {
@@ -694,7 +697,11 @@ impl Signer {
694
697
}
695
698
696
699
#[ cfg( any( test, feature = "testing" ) ) ]
697
- fn send_block_response ( & mut self , block_response : BlockResponse ) {
700
+ fn send_block_response (
701
+ & mut self ,
702
+ block : Option < & NakamotoBlock > ,
703
+ block_response : BlockResponse ,
704
+ ) {
698
705
const NUM_REPEATS : usize = 1 ;
699
706
let mut count = 0 ;
700
707
let public_keys = TEST_REPEAT_PROPOSAL_RESPONSE . get ( ) ;
@@ -704,16 +711,20 @@ impl Signer {
704
711
count = NUM_REPEATS ;
705
712
}
706
713
while count <= NUM_REPEATS {
707
- self . impl_send_block_response ( block_response. clone ( ) ) ;
714
+ self . impl_send_block_response ( block , block_response. clone ( ) ) ;
708
715
709
716
count += 1 ;
710
717
sleep_ms ( 1000 ) ;
711
718
}
712
719
}
713
720
714
721
#[ cfg( not( any( test, feature = "testing" ) ) ) ]
715
- fn send_block_response ( & mut self , block_response : BlockResponse ) {
716
- self . impl_send_block_response ( block_response)
722
+ fn send_block_response (
723
+ & mut self ,
724
+ block : & Option < NakamotoBlock > ,
725
+ block_response : BlockResponse ,
726
+ ) {
727
+ self . impl_send_block_response ( block, block_response)
717
728
}
718
729
719
730
/// Handle signer state update message
@@ -842,7 +853,7 @@ impl Signer {
842
853
843
854
if let Some ( block_response) = block_response {
844
855
// We know proposal is invalid. Send rejection message, do not do further validation and do not store it.
845
- self . send_block_response ( block_response) ;
856
+ self . send_block_response ( Some ( & block_info . block ) , block_response) ;
846
857
} else {
847
858
// Just in case check if the last block validation submission timed out.
848
859
self . check_submitted_block_proposal ( ) ;
@@ -896,7 +907,7 @@ impl Signer {
896
907
return ;
897
908
} ;
898
909
899
- self . impl_send_block_response ( block_response) ;
910
+ self . impl_send_block_response ( Some ( & block_info . block ) , block_response) ;
900
911
}
901
912
902
913
/// Handle block response messages from a signer
@@ -1032,7 +1043,7 @@ impl Signer {
1032
1043
warn ! ( "{self}: Failed to mark block as locally rejected: {e:?}" ) ;
1033
1044
}
1034
1045
} ;
1035
- self . impl_send_block_response ( block_response) ;
1046
+ self . impl_send_block_response ( Some ( & block_info . block ) , block_response) ;
1036
1047
self . signer_db
1037
1048
. insert_block ( & block_info)
1038
1049
. unwrap_or_else ( |e| self . handle_insert_block_error ( e) ) ;
@@ -1139,7 +1150,12 @@ impl Signer {
1139
1150
. unwrap_or_else ( |e| warn ! ( "{self}: Failed to remove pending block validation: {e:?}" ) ) ;
1140
1151
1141
1152
if let Some ( response) = block_response {
1142
- self . impl_send_block_response ( response) ;
1153
+ let block = self
1154
+ . signer_db
1155
+ . block_lookup ( & signer_sig_hash)
1156
+ . unwrap_or_default ( )
1157
+ . map ( |info| info. block ) ;
1158
+ self . impl_send_block_response ( block. as_ref ( ) , response) ;
1143
1159
} ;
1144
1160
1145
1161
// Check if there is a pending block validation that we need to submit to the node
@@ -1232,7 +1248,7 @@ impl Signer {
1232
1248
warn ! ( "{self}: Failed to mark block as locally rejected: {e:?}" ) ;
1233
1249
}
1234
1250
} ;
1235
- self . impl_send_block_response ( rejection) ;
1251
+ self . impl_send_block_response ( Some ( & block_info . block ) , rejection) ;
1236
1252
1237
1253
self . signer_db
1238
1254
. insert_block ( & block_info)
0 commit comments