@@ -29,8 +29,9 @@ use {serde, serde_json};
29
29
30
30
use crate :: chainstate:: burn:: db:: sortdb:: SortitionDB ;
31
31
use crate :: chainstate:: burn:: BlockSnapshot ;
32
- use crate :: chainstate:: nakamoto:: { NakamotoBlock , NakamotoChainState , NakamotoStagingBlocksConn } ;
33
- use crate :: chainstate:: nakamoto:: StacksDBIndexed ;
32
+ use crate :: chainstate:: nakamoto:: {
33
+ NakamotoBlock , NakamotoChainState , NakamotoStagingBlocksConn , StacksDBIndexed ,
34
+ } ;
34
35
use crate :: chainstate:: stacks:: db:: StacksChainState ;
35
36
use crate :: chainstate:: stacks:: Error as ChainError ;
36
37
use crate :: net:: api:: getblock_v3:: NakamotoBlockStream ;
@@ -157,9 +158,11 @@ impl GetSortitionHandler {
157
158
sortition_sn : BlockSnapshot ,
158
159
sortdb : & SortitionDB ,
159
160
chainstate : & mut StacksChainState ,
160
- tip : & StacksBlockId
161
+ tip : & StacksBlockId ,
161
162
) -> Result < SortitionInfo , ChainError > {
162
- let is_shadow = chainstate. nakamoto_blocks_db ( ) . is_shadow_tenure ( & sortition_sn. consensus_hash ) ?;
163
+ let is_shadow = chainstate
164
+ . nakamoto_blocks_db ( )
165
+ . is_shadow_tenure ( & sortition_sn. consensus_hash ) ?;
163
166
let ( miner_pk_hash160, stacks_parent_ch, committed_block_hash, last_sortition_ch) =
164
167
if !sortition_sn. sortition && !is_shadow {
165
168
let handle = sortdb. index_handle ( & sortition_sn. sortition_id ) ;
@@ -168,13 +171,27 @@ impl GetSortitionHandler {
168
171
( None , None , None , Some ( last_sortition. consensus_hash ) )
169
172
} else if !sortition_sn. sortition && is_shadow {
170
173
// this is a shadow tenure.
171
- let parent_tenure_ch = chainstate. index_conn ( ) . get_parent_tenure_consensus_hash ( tip, & sortition_sn. consensus_hash ) ?
174
+ let parent_tenure_ch = chainstate
175
+ . index_conn ( )
176
+ . get_parent_tenure_consensus_hash ( tip, & sortition_sn. consensus_hash ) ?
172
177
. ok_or_else ( || DBError :: NotFoundError ) ?;
173
-
174
- let parent_tenure_start_header = NakamotoChainState :: get_nakamoto_tenure_start_block_header ( & mut chainstate. index_conn ( ) , tip, & parent_tenure_ch) ?
178
+
179
+ let parent_tenure_start_header =
180
+ NakamotoChainState :: get_nakamoto_tenure_start_block_header (
181
+ & mut chainstate. index_conn ( ) ,
182
+ tip,
183
+ & parent_tenure_ch,
184
+ ) ?
175
185
. ok_or_else ( || DBError :: NotFoundError ) ?;
176
186
177
- ( Some ( Hash160 ( [ 0x00 ; 20 ] ) ) , Some ( parent_tenure_ch. clone ( ) ) , Some ( BlockHeaderHash ( parent_tenure_start_header. index_block_hash ( ) . 0 ) ) , Some ( parent_tenure_ch) )
187
+ (
188
+ Some ( Hash160 ( [ 0x00 ; 20 ] ) ) ,
189
+ Some ( parent_tenure_ch. clone ( ) ) ,
190
+ Some ( BlockHeaderHash (
191
+ parent_tenure_start_header. index_block_hash ( ) . 0 ,
192
+ ) ) ,
193
+ Some ( parent_tenure_ch) ,
194
+ )
178
195
} else {
179
196
let block_commit = SortitionDB :: get_block_commit ( sortdb. conn ( ) , & sortition_sn. winning_block_txid , & sortition_sn. sortition_id ) ?
180
197
. ok_or_else ( || {
@@ -324,7 +341,12 @@ impl RPCRequestHandler for GetSortitionHandler {
324
341
}
325
342
} ;
326
343
let sortition_sn = query_result?. ok_or_else ( || ChainError :: NoSuchBlockError ) ?;
327
- Self :: get_sortition_info ( sortition_sn, sortdb, chainstate, & network. stacks_tip . block_id ( ) )
344
+ Self :: get_sortition_info (
345
+ sortition_sn,
346
+ sortdb,
347
+ chainstate,
348
+ & network. stacks_tip . block_id ( ) ,
349
+ )
328
350
} ) ;
329
351
330
352
let block = match result {
@@ -358,7 +380,12 @@ impl RPCRequestHandler for GetSortitionHandler {
358
380
& last_sortition_ch,
359
381
) ?
360
382
. ok_or_else ( || ChainError :: NoSuchBlockError ) ?;
361
- Self :: get_sortition_info ( last_sortition_sn, sortdb, chainstate, & network. stacks_tip . block_id ( ) )
383
+ Self :: get_sortition_info (
384
+ last_sortition_sn,
385
+ sortdb,
386
+ chainstate,
387
+ & network. stacks_tip . block_id ( ) ,
388
+ )
362
389
} ) ;
363
390
let last_block = match result {
364
391
Ok ( block) => block,
0 commit comments