@@ -3716,30 +3716,44 @@ impl StacksChainState {
3716
3716
blocks_conn : & DBConn ,
3717
3717
staging_block : & StagingBlock ,
3718
3718
) -> Result < Option < Vec < StacksMicroblock > > , Error > {
3719
- if staging_block. parent_microblock_hash == EMPTY_MICROBLOCK_PARENT_HASH
3720
- && staging_block. parent_microblock_seq == 0
3721
- {
3719
+ Self :: inner_find_parent_microblock_stream (
3720
+ blocks_conn,
3721
+ & staging_block. anchored_block_hash ,
3722
+ & staging_block. parent_anchored_block_hash ,
3723
+ & staging_block. parent_consensus_hash ,
3724
+ & staging_block. parent_microblock_hash ,
3725
+ staging_block. parent_microblock_seq ,
3726
+ )
3727
+ }
3728
+
3729
+ /// Allow `find_parent_microblock_stream()` to be called without `StagingBlock`
3730
+ pub fn inner_find_parent_microblock_stream (
3731
+ blocks_conn : & DBConn ,
3732
+ anchored_block_hash : & BlockHeaderHash ,
3733
+ parent_anchored_block_hash : & BlockHeaderHash ,
3734
+ parent_consensus_hash : & ConsensusHash ,
3735
+ parent_microblock_hash : & BlockHeaderHash ,
3736
+ parent_microblock_seq : u16 ,
3737
+ ) -> Result < Option < Vec < StacksMicroblock > > , Error > {
3738
+ if * parent_microblock_hash == EMPTY_MICROBLOCK_PARENT_HASH && parent_microblock_seq == 0 {
3722
3739
// no parent microblocks, ever
3723
3740
return Ok ( Some ( vec ! [ ] ) ) ;
3724
3741
}
3725
3742
3726
3743
// find the microblock stream fork that this block confirms
3727
3744
match StacksChainState :: load_microblock_stream_fork (
3728
3745
blocks_conn,
3729
- & staging_block . parent_consensus_hash ,
3730
- & staging_block . parent_anchored_block_hash ,
3731
- & staging_block . parent_microblock_hash ,
3746
+ parent_consensus_hash,
3747
+ parent_anchored_block_hash,
3748
+ parent_microblock_hash,
3732
3749
) ? {
3733
3750
Some ( microblocks) => {
3734
3751
return Ok ( Some ( microblocks) ) ;
3735
3752
}
3736
3753
None => {
3737
3754
// parent microblocks haven't arrived yet, or there are none
3738
3755
debug ! (
3739
- "No parent microblock stream for {}: expected a stream with tail {},{}" ,
3740
- staging_block. anchored_block_hash,
3741
- staging_block. parent_microblock_hash,
3742
- staging_block. parent_microblock_seq
3756
+ "No parent microblock stream for {anchored_block_hash}: expected a stream with tail {parent_microblock_hash},{parent_microblock_seq}" ,
3743
3757
) ;
3744
3758
return Ok ( None ) ;
3745
3759
}
0 commit comments