Json::Value toJson(dev::eth::BlockHeader const& _bi, BlockDetails const& _bd, UncleHashes const& _us, Transactions const& _ts, SealEngineFace* _face) { Json::Value res = toJson(_bi, _face); if (_bi) { res["totalDifficulty"] = toJS(_bd.totalDifficulty); res["size"] = toJS(_bd.size); res["uncles"] = Json::Value(Json::arrayValue); for (h256 h: _us) res["uncles"].append(toJS(h)); res["transactions"] = Json::Value(Json::arrayValue); for (unsigned i = 0; i < _ts.size(); i++) res["transactions"].append(toJson(_ts[i], std::make_pair(_bi.hash(), i), (BlockNumber)_bi.number())); } return res; }
Json::Value toJson(dev::eth::BlockHeader const& _bi, SealEngineFace* _sealer) { Json::Value res; if (_bi) { DEV_IGNORE_EXCEPTIONS(res["hash"] = toJS(_bi.hash())); res["parentHash"] = toJS(_bi.parentHash()); res["sha3Uncles"] = toJS(_bi.sha3Uncles()); res["author"] = toJS(_bi.author()); res["stateRoot"] = toJS(_bi.stateRoot()); res["transactionsRoot"] = toJS(_bi.transactionsRoot()); res["receiptsRoot"] = toJS(_bi.receiptsRoot()); res["number"] = toJS(_bi.number()); res["gasUsed"] = toJS(_bi.gasUsed()); res["gasLimit"] = toJS(_bi.gasLimit()); res["extraData"] = toJS(_bi.extraData()); res["logsBloom"] = toJS(_bi.logBloom()); res["timestamp"] = toJS(_bi.timestamp()); // TODO: remove once JSONRPC spec is updated to use "author" over "miner". res["miner"] = toJS(_bi.author()); if (_sealer) for (auto const& i: _sealer->jsInfo(_bi)) res[i.first] = i.second; } return res; }