@@ -156,21 +156,11 @@ UniValue blockheaderToJSON(const CBlockIndex* tip, const CBlockIndex* blockindex
156
156
157
157
UniValue blockToJSON (const CBlock& block, const CBlockIndex* tip, const CBlockIndex* blockindex, bool txDetails)
158
158
{
159
- // Serialize passed information without accessing chain state of the active chain!
160
- AssertLockNotHeld (cs_main); // For performance reasons
159
+ UniValue result = blockheaderToJSON (tip, blockindex);
161
160
162
- UniValue result (UniValue::VOBJ);
163
- result.pushKV (" hash" , blockindex->GetBlockHash ().GetHex ());
164
- const CBlockIndex* pnext;
165
- int confirmations = ComputeNextBlockAndDepth (tip, blockindex, pnext);
166
- result.pushKV (" confirmations" , confirmations);
167
161
result.pushKV (" strippedsize" , (int )::GetSerializeSize (block, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS));
168
162
result.pushKV (" size" , (int )::GetSerializeSize (block, PROTOCOL_VERSION));
169
163
result.pushKV (" weight" , (int )::GetBlockWeight (block));
170
- result.pushKV (" height" , blockindex->nHeight );
171
- result.pushKV (" version" , block.nVersion );
172
- result.pushKV (" versionHex" , strprintf (" %08x" , block.nVersion ));
173
- result.pushKV (" merkleroot" , block.hashMerkleRoot .GetHex ());
174
164
UniValue txs (UniValue::VARR);
175
165
if (txDetails) {
176
166
CBlockUndo blockUndo;
@@ -189,18 +179,7 @@ UniValue blockToJSON(const CBlock& block, const CBlockIndex* tip, const CBlockIn
189
179
}
190
180
}
191
181
result.pushKV (" tx" , txs);
192
- result.pushKV (" time" , block.GetBlockTime ());
193
- result.pushKV (" mediantime" , (int64_t )blockindex->GetMedianTimePast ());
194
- result.pushKV (" nonce" , (uint64_t )block.nNonce );
195
- result.pushKV (" bits" , strprintf (" %08x" , block.nBits ));
196
- result.pushKV (" difficulty" , GetDifficulty (blockindex));
197
- result.pushKV (" chainwork" , blockindex->nChainWork .GetHex ());
198
- result.pushKV (" nTx" , (uint64_t )blockindex->nTx );
199
182
200
- if (blockindex->pprev )
201
- result.pushKV (" previousblockhash" , blockindex->pprev ->GetBlockHash ().GetHex ());
202
- if (pnext)
203
- result.pushKV (" nextblockhash" , pnext->GetBlockHash ().GetHex ());
204
183
return result;
205
184
}
206
185
0 commit comments