Browse Source

Additional APIs and good defaults for Client & JSAPI.

cl-refactor
Gav Wood 11 years ago
parent
commit
d224cc84a7
  1. 3
      libethereum/Client.h
  2. 3
      libethereum/State.h
  3. 2
      libqethereum/QEthereum.cpp

3
libethereum/Client.h

@ -235,6 +235,9 @@ public:
/// Get the fee associated for a transaction with the given data.
static u256 txGas(uint _dataCount, u256 _gas = 0) { return c_txDataGas * _dataCount + c_txGas + _gas; }
/// Get the remaining gas limit in this block.
u256 gasLimitRemaining() const { return m_postMine.gasLimitRemaining(); }
// [PRIVATE API - only relevant for base clients, not available in general]
eth::State state(unsigned _txi, h256 _block) const;

3
libethereum/State.h

@ -192,6 +192,9 @@ public:
u256 execute(bytes const& _rlp, bytes* o_output = nullptr, bool _commit = true) { return execute(&_rlp, o_output, _commit); }
u256 execute(bytesConstRef _rlp, bytes* o_output = nullptr, bool _commit = true);
/// Get the remaining gas limit in this block.
u256 gasLimitRemaining() const { return m_currentBlock.gasLimit - gasUsed(); }
/// Check if the address is in use.
bool addressInUse(Address _address) const;

2
libqethereum/QEthereum.cpp

@ -413,7 +413,7 @@ void QEthereum::doTransact(QString _json)
if (!t.gasPrice)
t.gasPrice = 10 * eth::szabo;
if (!t.gas)
t.gas = client()->balanceAt(KeyPair(t.from).address()) / t.gasPrice;
t.gas = min<u256>(client()->gasLimitRemaining(), client()->balanceAt(KeyPair(t.from).address()) / t.gasPrice);
if (t.to)
client()->transact(t.from, t.value, t.to, t.data, t.gas, t.gasPrice);
else

Loading…
Cancel
Save