Browse Source

fixed transactionHashes && getTransactionByHash

cl-refactor
Marek Kotewicz 10 years ago
parent
commit
8e65751c2d
  1. 10
      libethereum/Client.cpp
  2. 2
      libethereum/Client.h
  3. 4
      libethereum/Interface.h
  4. 15
      libweb3jsonrpc/WebThreeStubServerBase.cpp
  5. 10
      mix/MixClient.cpp
  6. 2
      mix/MixClient.h

10
libethereum/Client.cpp

@ -724,6 +724,11 @@ bytes Client::codeAt(Address _a, int _block) const
return asOf(_block).code(_a);
}
Transaction Client::transaction(h256 _transactionHash) const
{
return Transaction(m_bc.transaction(_transactionHash), CheckSignature::Range);
}
Transaction Client::transaction(h256 _blockHash, unsigned _i) const
{
auto bl = m_bc.block(_blockHash);
@ -768,6 +773,11 @@ Transactions Client::transactions(h256 _blockHash) const
return res;
}
TransactionHashes Client::transactionHashes(h256 _blockHash) const
{
return m_bc.transactionHashes(_blockHash);
}
LocalisedLogEntries Client::logs(unsigned _watchId) const
{
try {

2
libethereum/Client.h

@ -236,11 +236,13 @@ public:
virtual h256 hashFromNumber(unsigned _number) const { return m_bc.numberHash(_number); }
virtual BlockInfo blockInfo(h256 _hash) const { return BlockInfo(m_bc.block(_hash)); }
virtual BlockDetails blockDetails(h256 _hash) const { return m_bc.details(_hash); }
virtual Transaction transaction(h256 _transactionHash) const;
virtual Transaction transaction(h256 _blockHash, unsigned _i) const;
virtual BlockInfo uncle(h256 _blockHash, unsigned _i) const;
virtual unsigned transactionCount(h256 _blockHash) const;
virtual unsigned uncleCount(h256 _blockHash) const;
virtual Transactions transactions(h256 _blockHash) const;
virtual TransactionHashes transactionHashes(h256 _blockHash) const;
/// Differences between transactions.
using Interface::diff;

4
libethereum/Interface.h

@ -37,6 +37,8 @@ namespace dev
namespace eth
{
using TransactionHashes = h256s;
/**
* @brief Main API hub for interfacing with Ethereum.
*/
@ -101,11 +103,13 @@ public:
virtual h256 hashFromNumber(unsigned _number) const = 0;
virtual BlockInfo blockInfo(h256 _hash) const = 0;
virtual BlockDetails blockDetails(h256 _hash) const = 0;
virtual Transaction transaction(h256 _transactionHash) const = 0;
virtual Transaction transaction(h256 _blockHash, unsigned _i) const = 0;
virtual BlockInfo uncle(h256 _blockHash, unsigned _i) const = 0;
virtual unsigned transactionCount(h256 _blockHash) const = 0;
virtual unsigned uncleCount(h256 _blockHash) const = 0;
virtual Transactions transactions(h256 _blockHash) const = 0;
virtual TransactionHashes transactionHashes(h256 _blockHash) const = 0;
// [EXTRA API]:

15
libweb3jsonrpc/WebThreeStubServerBase.cpp

@ -88,6 +88,15 @@ static Json::Value toJson(dev::eth::BlockInfo const& _bi, Transactions const& _t
return res;
}
static Json::Value toJson(dev::eth::BlockInfo const& _bi, TransactionHashes const& _ts)
{
Json::Value res = toJson(_bi);
res["transactions"] = Json::Value(Json::arrayValue);
for (h256 const& t: _ts)
res["transactions"].append(toJS(t));
return res;
}
static Json::Value toJson(dev::eth::TransactionSkeleton const& _t)
{
Json::Value res;
@ -565,7 +574,7 @@ Json::Value WebThreeStubServerBase::eth_getBlockByHash(string const& _blockHash,
return toJson(client()->blockInfo(hash), client()->transactions(hash));
}
return toJson(client()->blockInfo(hash));
return toJson(client()->blockInfo(hash), client()->transactionHashes(hash));
}
Json::Value WebThreeStubServerBase::eth_getBlockByNumber(string const& _blockNumber, bool _includeTransactions)
@ -603,9 +612,7 @@ Json::Value WebThreeStubServerBase::eth_getTransactionByHash(string const& _tran
throw jsonrpc::JsonRpcException(jsonrpc::Errors::ERROR_RPC_INVALID_PARAMS);
}
// return toJson(client()->transaction(hash, index));
// TODO:
return "";
return toJson(client()->transaction(hash));
}
Json::Value WebThreeStubServerBase::eth_getTransactionByBlockHashAndIndex(string const& _blockHash, string const& _transactionIndex)

10
mix/MixClient.cpp

@ -462,6 +462,11 @@ eth::BlockDetails MixClient::blockDetails(h256 _hash) const
return bc().details(_hash);
}
Transaction MixClient::transaction(h256 _transactionHash) const
{
return Transaction(bc().transaction(_transactionHash), CheckSignature::Range);
}
eth::Transaction MixClient::transaction(h256 _blockHash, unsigned _i) const
{
auto bl = bc().block(_blockHash);
@ -506,6 +511,11 @@ Transactions MixClient::transactions(h256 _blockHash) const
return res;
}
TransactionHashes MixClient::transactionHashes(h256 _blockHash) const
{
return bc().transactionHashes(_blockHash);
}
unsigned MixClient::number() const
{
return bc().number();

2
mix/MixClient.h

@ -68,11 +68,13 @@ public:
h256 hashFromNumber(unsigned _number) const override;
eth::BlockInfo blockInfo(h256 _hash) const override;
eth::BlockDetails blockDetails(h256 _hash) const override;
eth::Transaction transaction(h256 _transactionHash) const override;
eth::Transaction transaction(h256 _blockHash, unsigned _i) const override;
eth::BlockInfo uncle(h256 _blockHash, unsigned _i) const override;
unsigned transactionCount(h256 _blockHash) const override;
unsigned uncleCount(h256 _blockHash) const override;
eth::Transactions transactions(h256 _blockHash) const override;
eth::TransactionHashes transactionHashes(h256 _blockHash) const override;
unsigned number() const override;
eth::Transactions pending() const override;
eth::StateDiff diff(unsigned _txi, h256 _block) const override;

Loading…
Cancel
Save