|
|
@ -57,58 +57,70 @@ const unsigned dev::SensibleHttpPort = 8080; |
|
|
|
static Json::Value toJson(dev::eth::BlockInfo const& _bi) |
|
|
|
{ |
|
|
|
Json::Value res; |
|
|
|
res["hash"] = toJS(_bi.hash); |
|
|
|
res["parentHash"] = toJS(_bi.parentHash); |
|
|
|
res["sha3Uncles"] = toJS(_bi.sha3Uncles); |
|
|
|
res["miner"] = toJS(_bi.coinbaseAddress); |
|
|
|
res["stateRoot"] = toJS(_bi.stateRoot); |
|
|
|
res["transactionsRoot"] = toJS(_bi.transactionsRoot); |
|
|
|
res["difficulty"] = toJS(_bi.difficulty); |
|
|
|
res["number"] = toJS(_bi.number); |
|
|
|
res["gasUsed"] = toJS(_bi.gasUsed); |
|
|
|
res["gasLimit"] = toJS(_bi.gasLimit); |
|
|
|
res["timestamp"] = toJS(_bi.timestamp); |
|
|
|
res["extraData"] = toJS(_bi.extraData); |
|
|
|
res["nonce"] = toJS(_bi.nonce); |
|
|
|
res["logsBloom"] = toJS(_bi.logBloom); |
|
|
|
if (_bi) |
|
|
|
{ |
|
|
|
res["hash"] = toJS(_bi.hash); |
|
|
|
res["parentHash"] = toJS(_bi.parentHash); |
|
|
|
res["sha3Uncles"] = toJS(_bi.sha3Uncles); |
|
|
|
res["miner"] = toJS(_bi.coinbaseAddress); |
|
|
|
res["stateRoot"] = toJS(_bi.stateRoot); |
|
|
|
res["transactionsRoot"] = toJS(_bi.transactionsRoot); |
|
|
|
res["difficulty"] = toJS(_bi.difficulty); |
|
|
|
res["number"] = toJS(_bi.number); |
|
|
|
res["gasUsed"] = toJS(_bi.gasUsed); |
|
|
|
res["gasLimit"] = toJS(_bi.gasLimit); |
|
|
|
res["timestamp"] = toJS(_bi.timestamp); |
|
|
|
res["extraData"] = toJS(_bi.extraData); |
|
|
|
res["nonce"] = toJS(_bi.nonce); |
|
|
|
res["logsBloom"] = toJS(_bi.logBloom); |
|
|
|
} |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
static Json::Value toJson(dev::eth::Transaction const& _t) |
|
|
|
{ |
|
|
|
Json::Value res; |
|
|
|
res["hash"] = toJS(_t.sha3()); |
|
|
|
res["input"] = toJS(_t.data()); |
|
|
|
res["to"] = _t.isCreation() ? Json::Value() : toJS(_t.receiveAddress()); |
|
|
|
res["from"] = toJS(_t.safeSender()); |
|
|
|
res["gas"] = toJS(_t.gas()); |
|
|
|
res["gasPrice"] = toJS(_t.gasPrice()); |
|
|
|
res["nonce"] = toJS(_t.nonce()); |
|
|
|
res["value"] = toJS(_t.value()); |
|
|
|
if (_t) |
|
|
|
{ |
|
|
|
res["hash"] = toJS(_t.sha3()); |
|
|
|
res["input"] = toJS(_t.data()); |
|
|
|
res["to"] = _t.isCreation() ? Json::Value() : toJS(_t.receiveAddress()); |
|
|
|
res["from"] = toJS(_t.safeSender()); |
|
|
|
res["gas"] = toJS(_t.gas()); |
|
|
|
res["gasPrice"] = toJS(_t.gasPrice()); |
|
|
|
res["nonce"] = toJS(_t.nonce()); |
|
|
|
res["value"] = toJS(_t.value()); |
|
|
|
} |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
static Json::Value toJson(dev::eth::BlockInfo const& _bi, UncleHashes const& _us, Transactions const& _ts) |
|
|
|
{ |
|
|
|
Json::Value res = toJson(_bi); |
|
|
|
res["uncles"] = Json::Value(Json::arrayValue); |
|
|
|
for (h256 h: _us) |
|
|
|
res["uncles"].append(toJS(h)); |
|
|
|
res["transactions"] = Json::Value(Json::arrayValue); |
|
|
|
for (Transaction const& t: _ts) |
|
|
|
res["transactions"].append(toJson(t)); |
|
|
|
if (_bi) |
|
|
|
{ |
|
|
|
res["uncles"] = Json::Value(Json::arrayValue); |
|
|
|
for (h256 h: _us) |
|
|
|
res["uncles"].append(toJS(h)); |
|
|
|
res["transactions"] = Json::Value(Json::arrayValue); |
|
|
|
for (Transaction const& t: _ts) |
|
|
|
res["transactions"].append(toJson(t)); |
|
|
|
} |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
static Json::Value toJson(dev::eth::BlockInfo const& _bi, UncleHashes const& _us, TransactionHashes const& _ts) |
|
|
|
{ |
|
|
|
Json::Value res = toJson(_bi); |
|
|
|
res["uncles"] = Json::Value(Json::arrayValue); |
|
|
|
for (h256 h: _us) |
|
|
|
res["uncles"].append(toJS(h)); |
|
|
|
res["transactions"] = Json::Value(Json::arrayValue); |
|
|
|
for (h256 const& t: _ts) |
|
|
|
res["transactions"].append(toJS(t)); |
|
|
|
if (_bi) |
|
|
|
{ |
|
|
|
res["uncles"] = Json::Value(Json::arrayValue); |
|
|
|
for (h256 h: _us) |
|
|
|
res["uncles"].append(toJS(h)); |
|
|
|
res["transactions"] = Json::Value(Json::arrayValue); |
|
|
|
for (h256 const& t: _ts) |
|
|
|
res["transactions"].append(toJS(t)); |
|
|
|
} |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|