From 0a46ee464b5c1e6b4d1e942c694d1dd6b068c350 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 25 Dec 2014 11:45:10 +0000 Subject: [PATCH] Speed up basic calls. --- libethereum/Client.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index c7ed4500c..edad31c6d 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -27,6 +27,7 @@ #include #include #include "Defaults.h" +#include "Executive.h" #include "EthereumHost.h" using namespace std; using namespace dev; @@ -355,28 +356,24 @@ bytes Client::call(Secret _secret, u256 _value, Address _dest, bytes const& _dat bytes Client::call(Address _dest, bytes const& _data, u256 _gas, u256 _value, u256 _gasPrice) { - bytes out; try { - u256 n; State temp; - KeyPair k = KeyPair::create(); - // cdebug << "Nonce at " << toAddress(_secret) << " pre:" << m_preMine.transactionsFrom(toAddress(_secret)) << " post:" << m_postMine.transactionsFrom(toAddress(_secret)); +// cdebug << "Nonce at " << toAddress(_secret) << " pre:" << m_preMine.transactionsFrom(toAddress(_secret)) << " post:" << m_postMine.transactionsFrom(toAddress(_secret)); { ReadGuard l(x_stateDB); temp = m_postMine; - temp.addBalance(k.address(), _gas * _gasPrice + _value); - n = temp.transactionsFrom(k.address()); } - Transaction t(_value, _gasPrice, _gas, _dest, _data, n, k.secret()); - u256 gasUsed = temp.execute(m_bc, t.rlp(), &out, false); - (void)gasUsed; // TODO: do something with gasused which it returns. + Executive e(temp, LastHashes(), 0); + e.call(_dest, _dest, Address(), _value, _gasPrice, &_data, _gas, Address()); + e.go(); + return e.out().toBytes(); } catch (...) { // TODO: Some sort of notification of failure. } - return out; + return bytes(); } Address Client::transact(Secret _secret, u256 _endowment, bytes const& _init, u256 _gas, u256 _gasPrice)