Browse Source

Merge branch 'up-develop' into develop

cl-refactor
subtly 11 years ago
parent
commit
93852453b1
  1. 2
      CMakeLists.txt
  2. 22
      alethzero/MainWin.cpp
  3. 6
      libethereum/Client.cpp
  4. 2
      libethereum/PeerNetwork.cpp
  5. 11
      libethereum/State.cpp
  6. 1
      libethereum/State.h
  7. 6
      libethereum/Transaction.h

2
CMakeLists.txt

@ -5,7 +5,7 @@ set(CMAKE_AUTOMOC ON)
cmake_policy(SET CMP0015 NEW)
set(ETH_VERSION 0.2.6)
set(ETH_VERSION 0.2.8)
set(ETH_BUILD_TYPE ${CMAKE_BUILD_TYPE})
# Default HEADLESS to 0.

22
alethzero/MainWin.cpp

@ -144,10 +144,11 @@ void Main::refresh()
ui->transactionQueue->clear();
for (pair<h256, Transaction> const& i: m_client->pending())
{
ui->transactionQueue->addItem(QString("%1 @ %2 <- %3")
ui->transactionQueue->addItem(QString("%1 [%4] @ %2 <- %3")
.arg(formatBalance(i.second.value).c_str())
.arg(asHex(i.second.receiveAddress.asArray()).c_str())
.arg(asHex(i.second.sender().asArray()).c_str()) );
.arg(asHex(i.second.sender().asArray()).c_str())
.arg((unsigned)i.second.nonce));
}
ui->transactions->clear();
@ -159,10 +160,11 @@ void Main::refresh()
for (auto const& i: RLP(bc.block(h))[1])
{
Transaction t(i.data());
ui->transactions->addItem(QString("%1 @ %2 <- %3")
ui->transactions->addItem(QString("%1 [%4] @ %2 <- %3")
.arg(formatBalance(t.value).c_str())
.arg(asHex(t.receiveAddress.asArray()).c_str())
.arg(asHex(t.sender().asArray()).c_str()) );
.arg(asHex(t.sender().asArray()).c_str())
.arg((unsigned)t.nonce));
}
}
}
@ -302,7 +304,7 @@ void Main::on_send_clicked()
u256 totalReq = value() + fee();
m_client->lock();
for (auto i: m_myKeys)
if (m_client->state().balance(i.address()) >= totalReq)
if (m_client->state().balance(i.address()) >= totalReq && i.address() != Address(fromUserHex(ui->destination->text().toStdString())))
{
m_client->unlock();
Secret s = i.secret();
@ -310,7 +312,15 @@ void Main::on_send_clicked()
u256s data;
data.reserve(m_data.size());
for (QString const& i: m_data)
data.push_back(u256(i.toStdString()));
{
u256 d = 0;
try
{
d = u256(i.toStdString());
}
catch (...) {}
data.push_back(d);
}
m_client->transact(s, r, value(), data);
refresh();
return;

6
libethereum/Client.cpp

@ -98,15 +98,15 @@ void Client::stopMining()
void Client::transact(Secret _secret, Address _dest, u256 _amount, u256s _data)
{
m_lock.lock();
lock_guard<mutex> l(m_lock);
Transaction t;
t.nonce = m_s.transactionsFrom(toAddress(_secret));
cnote << "New transaction " << t;
t.nonce = m_mined.transactionsFrom(toAddress(_secret));
t.receiveAddress = _dest;
t.value = _amount;
t.data = _data;
t.sign(_secret);
m_tq.attemptImport(t.rlp());
m_lock.unlock();
m_changed = true;
}

2
libethereum/PeerNetwork.cpp

@ -70,7 +70,7 @@ bool eth::isPrivateAddress(bi::address _addressToCheck)
{
bi::address_v4 v4Address = _addressToCheck.to_v4();
bi::address_v4::bytes_type bytesToCheck = v4Address.to_bytes();
if (bytesToCheck[0] == 10)
if (bytesToCheck[0] == 10 || bytesToCheck[0] == 127)
return true;
if (bytesToCheck[0] == 172 && (bytesToCheck[1] >= 16 && bytesToCheck[1] <=31))
return true;

11
libethereum/State.cpp

@ -189,7 +189,7 @@ void State::commit()
bool State::sync(BlockChain const& _bc)
{
return sync(_bc, _bc.currentHash());
return sync(_bc, _bc.currentHash());
}
bool State::sync(BlockChain const& _bc, h256 _block)
@ -414,8 +414,6 @@ u256 State::playback(bytesConstRef _block, BlockInfo const& _grandParent, bool _
// (i.e. all the transactions we executed).
void State::commitToMine(BlockChain const& _bc)
{
cnote << "Commiting to mine on" << m_previousBlock.hash;
if (m_currentBlock.sha3Transactions != h256() || m_currentBlock.sha3Uncles != h256())
return;
@ -454,12 +452,19 @@ void State::commitToMine(BlockChain const& _bc)
// Commit any and all changes to the trie that are in the cache, then update the state root accordingly.
commit();
m_currentBlock.stateRoot = m_state.root();
m_currentBlock.parentHash = m_previousBlock.hash;
}
MineInfo State::mine(uint _msTimeout)
{
if (m_previousBlock.hash != m_committedPreviousHash)
{
m_committedPreviousHash = m_committedPreviousHash;
cnote << "Commiting to mine on" << m_previousBlock.hash;
}
// Update timestamp according to clock.
m_currentBlock.timestamp = time(0);

1
libethereum/State.h

@ -224,6 +224,7 @@ private:
BlockInfo m_currentBlock; ///< The current block's information.
bytes m_currentBytes; ///< The current block.
uint m_currentNumber;
h256 m_committedPreviousHash; ///< Hash of previous block that we are committing to mine.
bytes m_currentTxs;
bytes m_currentUncles;

6
libethereum/Transaction.h

@ -61,6 +61,12 @@ struct Transaction
using Transactions = std::vector<Transaction>;
inline std::ostream& operator<<(std::ostream& _out, Transaction const& _t)
{
_out << "{" << _t.receiveAddress << "/" << _t.nonce << "*" << _t.value << "}";
return _out;
}
}

Loading…
Cancel
Save