99using Blockcore . Features . BlockStore . AddressIndexing ;
1010using Blockcore . Features . BlockStore . Api . Models ;
1111using Blockcore . Features . BlockStore . Models ;
12+ using Blockcore . Features . Consensus ;
1213using Blockcore . Interfaces ;
1314using Blockcore . Networks ;
1415using Blockcore . Utilities ;
@@ -48,14 +49,17 @@ public class BlockStoreController : Controller
4849 /// <summary>UTXO indexer.</summary>
4950 private readonly IUtxoIndexer utxoIndexer ;
5051
52+ private readonly IStakeChain stakeChain ;
53+
5154 public BlockStoreController (
5255 Network network ,
5356 ILoggerFactory loggerFactory ,
5457 IBlockStore blockStore ,
5558 IChainState chainState ,
5659 ChainIndexer chainIndexer ,
5760 IAddressIndexer addressIndexer ,
58- IUtxoIndexer utxoIndexer )
61+ IUtxoIndexer utxoIndexer ,
62+ IStakeChain stakeChain )
5963 {
6064 Guard . NotNull ( network , nameof ( network ) ) ;
6165 Guard . NotNull ( loggerFactory , nameof ( loggerFactory ) ) ;
@@ -69,6 +73,7 @@ public BlockStoreController(
6973 this . chainState = chainState ;
7074 this . chainIndexer = chainIndexer ;
7175 this . utxoIndexer = utxoIndexer ;
76+ this . stakeChain = stakeChain ;
7277 this . logger = loggerFactory . CreateLogger ( this . GetType ( ) . FullName ) ;
7378 }
7479
@@ -136,6 +141,15 @@ public IActionResult GetBlock([FromQuery] SearchByHashRequest query)
136141 blockModel . PosBlockSignature = posBlock . BlockSignature . ToHex ( this . network . Consensus . ConsensusFactory ) ;
137142 blockModel . PosBlockTrust = new Target ( chainedHeader . GetBlockTarget ( ) ) . ToUInt256 ( ) . ToString ( ) ;
138143 blockModel . PosChainTrust = chainedHeader . ChainWork . ToString ( ) ; // this should be similar to ChainWork
144+
145+ if ( this . stakeChain != null )
146+ {
147+ BlockStake blockStake = this . stakeChain . Get ( blockId ) ;
148+
149+ blockModel . PosModifierv2 = blockStake ? . StakeModifierV2 . ToString ( ) ;
150+ blockModel . PosFlags = blockStake ? . Flags == BlockFlag . BLOCK_PROOF_OF_STAKE ? "proof-of-stake" : "proof-of-work" ;
151+ blockModel . PosHashProof = blockStake ? . HashProof . ToString ( ) ;
152+ }
139153 }
140154
141155 return this . Json ( blockModel ) ;
0 commit comments