Browse Source

pair up hash with Address for transaction submission API.

cl-refactor
Gav Wood 10 years ago
parent
commit
d7357c8059
  1. 4
      libethereum/ClientBase.cpp
  2. 2
      libethereum/ClientBase.h
  3. 3
      libethereum/Interface.cpp
  4. 2
      libethereum/Interface.h
  5. 4
      libweb3jsonrpc/AccountHolder.cpp
  6. 3
      mix/ClientModel.cpp
  7. 4
      mix/MixClient.cpp
  8. 4
      mix/MixClient.h
  9. 2
      neth/main.cpp

4
libethereum/ClientBase.cpp

@ -45,7 +45,7 @@ State ClientBase::asOf(BlockNumber _h) const
return asOf(bc().numberHash(_h));
}
h256 ClientBase::submitTransaction(TransactionSkeleton const& _t, Secret const& _secret)
pair<h256, Address> ClientBase::submitTransaction(TransactionSkeleton const& _t, Secret const& _secret)
{
prepareForTransaction();
@ -59,7 +59,7 @@ h256 ClientBase::submitTransaction(TransactionSkeleton const& _t, Secret const&
StructuredLogger::transactionReceived(t.sha3().abridged(), t.sender().abridged());
cnote << "New transaction " << t;
return t.sha3();
return make_pair(t.sha3(), toAddress(ts.from, ts.nonce));
}
// TODO: remove try/catch, allow exceptions

2
libethereum/ClientBase.h

@ -77,7 +77,7 @@ public:
/// Submits the given transaction.
/// @returns the new transaction's hash.
virtual h256 submitTransaction(TransactionSkeleton const& _t, Secret const& _secret) override;
virtual std::pair<h256, Address> submitTransaction(TransactionSkeleton const& _t, Secret const& _secret) override;
using Interface::submitTransaction;
/// Makes the given call. Nothing is recorded into the state.

3
libethereum/Interface.cpp

@ -46,6 +46,5 @@ Address Interface::submitTransaction(Secret const& _secret, u256 const& _endowme
ts.gas = _gas;
ts.gasPrice = _gasPrice;
ts.nonce = _nonce;
submitTransaction(ts, _secret);
return toAddress(toAddress(_secret), _nonce);
return submitTransaction(ts, _secret).second;
}

2
libethereum/Interface.h

@ -67,7 +67,7 @@ public:
/// Submits a new transaction.
/// @returns the transaction's hash.
virtual h256 submitTransaction(TransactionSkeleton const& _t, Secret const& _secret) = 0;
virtual std::pair<h256, Address> submitTransaction(TransactionSkeleton const& _t, Secret const& _secret) = 0;
/// Submits the given message-call transaction.
void submitTransaction(Secret const& _secret, u256 const& _value, Address const& _dest, bytes const& _data = bytes(), u256 const& _gas = 10000, u256 const& _gasPrice = 10 * szabo, u256 const& _nonce = UndefinedU256);

4
libweb3jsonrpc/AccountHolder.cpp

@ -109,7 +109,7 @@ AddressHash SimpleAccountHolder::realAccounts() const
h256 SimpleAccountHolder::authenticate(dev::eth::TransactionSkeleton const& _t)
{
if (isRealAccount(_t.from))
return m_client()->submitTransaction(_t, m_keyManager.secret(_t.from, [&](){ return m_getPassword(_t.from); }));
return m_client()->submitTransaction(_t, m_keyManager.secret(_t.from, [&](){ return m_getPassword(_t.from); })).first;
else if (isProxyAccount(_t.from))
queueTransaction(_t);
return h256();
@ -118,7 +118,7 @@ h256 SimpleAccountHolder::authenticate(dev::eth::TransactionSkeleton const& _t)
h256 FixedAccountHolder::authenticate(dev::eth::TransactionSkeleton const& _t)
{
if (isRealAccount(_t.from))
return m_client()->submitTransaction(_t, m_accounts[_t.from]);
return m_client()->submitTransaction(_t, m_accounts[_t.from]).first;
else if (isProxyAccount(_t.from))
queueTransaction(_t);
return h256();

3
mix/ClientModel.cpp

@ -674,8 +674,7 @@ void ClientModel::debugRecord(unsigned _index)
Address ClientModel::deployContract(bytes const& _code, TransactionSettings const& _ctrTransaction)
{
Address newAddress = m_client->submitTransaction(_ctrTransaction.sender, _ctrTransaction.value, _code, _ctrTransaction.gas, _ctrTransaction.gasPrice, _ctrTransaction.gasAuto);
return newAddress;
return m_client->submitTransaction(_ctrTransaction.sender, _ctrTransaction.value, _code, _ctrTransaction.gas, _ctrTransaction.gasPrice, _ctrTransaction.gasAuto);
}
void ClientModel::callAddress(Address const& _contract, bytes const& _data, TransactionSettings const& _tr)

4
mix/MixClient.cpp

@ -303,14 +303,14 @@ State MixClient::asOf(h256 const& _block) const
return ret;
}
h256 MixClient::submitTransaction(eth::TransactionSkeleton const& _ts, Secret const& _secret, bool _gasAuto)
pair<h256, Address> MixClient::submitTransaction(eth::TransactionSkeleton const& _ts, Secret const& _secret, bool _gasAuto)
{
WriteGuard l(x_state);
TransactionSkeleton ts = _ts;
ts.nonce = m_state.transactionsFrom(toAddress(_secret));
eth::Transaction t(ts, _secret);
executeTransaction(t, m_state, false, _gasAuto, _secret);
return t.sha3();
return make_pair(t.sha3(), toAddress(ts.from, ts.nonce));
}
dev::eth::ExecutionResult MixClient::call(Address const& _from, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, bool _gasAuto, FudgeFactor _ff)

4
mix/MixClient.h

@ -58,8 +58,8 @@ public:
dev::eth::ExecutionResult create(Address const& _secret, u256 _value, bytes const& _data = bytes(), u256 _gas = 10000, u256 _gasPrice = 10 * eth::szabo, eth::BlockNumber _blockNumber = eth::PendingBlock, eth::FudgeFactor _ff = eth::FudgeFactor::Strict) override;
using ClientBase::submitTransaction;
virtual h256 submitTransaction(eth::TransactionSkeleton const& _ts, Secret const& _secret) override { return submitTransaction(_ts, _secret, false); }
h256 submitTransaction(eth::TransactionSkeleton const& _ts, Secret const& _secret, bool _gasAuto);
virtual std::pair<h256, Address> submitTransaction(eth::TransactionSkeleton const& _ts, Secret const& _secret) override { return submitTransaction(_ts, _secret, false); }
std::pair<h256, Address> submitTransaction(eth::TransactionSkeleton const& _ts, Secret const& _secret, bool _gasAuto);
dev::eth::ExecutionResult call(Address const& _secret, u256 _value, Address _dest, bytes const& _data, u256 _gas, u256 _gasPrice, eth::BlockNumber _blockNumber, bool _gasAuto, eth::FudgeFactor _ff = eth::FudgeFactor::Strict);
void setAddress(Address _us) override;

2
neth/main.cpp

@ -1057,9 +1057,7 @@ int main(int argc, char** argv)
else if (gas < minGas)
cwarn << "Minimum gas amount is" << minGas;
else
{
c->submitTransaction(us.secret(), endowment, init, gas);
}
}
}
else if (c && cmd == "inspect")

Loading…
Cancel
Save