Browse Source

UI statefulness.

cl-refactor
Gav Wood 11 years ago
parent
commit
5399507230
  1. 34
      TODO
  2. 5
      alethzero/Main.ui
  3. 37
      alethzero/MainWin.cpp
  4. 1
      alethzero/MainWin.h
  5. 30
      libethereum/PeerNetwork.cpp
  6. 7
      libethereum/PeerNetwork.h

34
TODO

@ -12,47 +12,39 @@ Better handling of corrupt blocks.
Network: Network:
- Crypto on network. TLS? - Crypto on network. TLS?
- Make work with IPv6 - Make work with IPv6
- Consider node addresses
CLI client CLI client
- Implement CLI option "--help". - Implement CLI option "--help".
- UPnP should be disablable.
- Should also attempt random port usage.
General: General:
- Better logging. - Better logging.
- Colours. - Colours.
- Time/thread/channel stamp.
- Move over to new system. - Move over to new system.
AlephZero: ### Gav
- Allow units to be selected for transactions.
### GAV
For PoC2: For PoC2:
Network:
- NotInChain will be very bad for new peers - it'll run through until the genesis.
- Check how many it has first.
BUG: need to discard transactions if nonce too old.
### Marko
Ubuntu builds Ubuntu builds
- Raring (branch, local, x64 only :-( ) - Raring (branch, local, x64 only :-( )
- Quantal (branch) (Launchpad) - Quantal (branch) (Launchpad)
- Saucy (master) (Launchpad) - Saucy (master) (Launchpad)
Server ### Alex
- Get PoC-2 running on dev server ready for switchover on release.
- Or just run on release @30300?
Network:
- NotInChain will be very bad for new peers - it'll run through until the genesis.
- Check how many it has first.
UI:
- State panel shouldn't show pending (i.e. post-mined) transactions.
Mac build
### ERIC ### Eric
Build: Windows build.
- Windows build.
LATER: LATER:

5
alethzero/Main.ui

@ -153,8 +153,11 @@
<enum>QFrame::NoFrame</enum> <enum>QFrame::NoFrame</enum>
</property> </property>
</widget> </widget>
<widget class="QWidget" name=""> <widget class="QWidget" name="layoutWidget">
<layout class="QGridLayout" name="gridLayout_2"> <layout class="QGridLayout" name="gridLayout_2">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<item row="1" column="0"> <item row="1" column="0">
<widget class="QLabel" name="label"> <widget class="QLabel" name="label">
<property name="text"> <property name="text">

37
alethzero/MainWin.cpp

@ -80,16 +80,28 @@ void Main::writeSettings()
} }
s.setValue("address", b); s.setValue("address", b);
// TODO: save peers - implement it in PeerNetwork though returning RLP bytes s.setValue("upnp", ui->upnp->isChecked());
/*for (uint i = 0; !s.value(QString("peer%1").arg(i)).isNull(); ++i) s.setValue("clientName", ui->clientName->text());
s.setValue("idealPeers", ui->idealPeers->value());
s.setValue("port", ui->port->value());
if (m_client->peerServer())
{ {
s.value(QString("peer%1").arg(i)).toString(); bytes d = m_client->peerServer()->savePeers();
}*/ m_peers = QByteArray((char*)d.data(), d.size());
}
s.setValue("peers", m_peers);
s.setValue("geometry", saveGeometry());
} }
void Main::readSettings() void Main::readSettings()
{ {
QSettings s("ethereum", "alethzero"); QSettings s("ethereum", "alethzero");
restoreGeometry(s.value("geometry").toByteArray());
QByteArray b = s.value("address").toByteArray(); QByteArray b = s.value("address").toByteArray();
if (b.isEmpty()) if (b.isEmpty())
m_myKeys.append(KeyPair::create()); m_myKeys.append(KeyPair::create());
@ -103,14 +115,11 @@ void Main::readSettings()
} }
} }
m_client->setAddress(m_myKeys.back().address()); m_client->setAddress(m_myKeys.back().address());
m_peers = s.value("peers").toByteArray();
writeSettings(); ui->upnp->setChecked(s.value("upnp", true).toBool());
ui->clientName->setText(s.value("clientName", "").toString());
// TODO: restore peers - implement it in PeerNetwork though giving RLP bytes ui->idealPeers->setValue(s.value("idealPeers", ui->idealPeers->value()).toInt());
/*for (uint i = 0; !s.value(QString("peer%1").arg(i)).isNull(); ++i) ui->port->setValue(s.value("port", ui->port->value()).toInt());
{
s.value(QString("peer%1").arg(i)).toString();
}*/
} }
void Main::refresh() void Main::refresh()
@ -247,7 +256,11 @@ void Main::on_net_triggered()
n += "/" ADD_QUOTES(ETH_BUILD_TYPE) "/" ADD_QUOTES(ETH_BUILD_PLATFORM); n += "/" ADD_QUOTES(ETH_BUILD_TYPE) "/" ADD_QUOTES(ETH_BUILD_PLATFORM);
m_client->setClientVersion(n); m_client->setClientVersion(n);
if (ui->net->isChecked()) if (ui->net->isChecked())
{
m_client->startNetwork(ui->port->value(), string(), 0, NodeMode::Full, ui->idealPeers->value(), std::string(), ui->upnp->isChecked()); m_client->startNetwork(ui->port->value(), string(), 0, NodeMode::Full, ui->idealPeers->value(), std::string(), ui->upnp->isChecked());
if (m_peers.size())
m_client->peerServer()->restorePeers(bytesConstRef((byte*)m_peers.data(), m_peers.size()));
}
else else
m_client->stopNetwork(); m_client->stopNetwork();
} }

1
alethzero/MainWin.h

@ -56,6 +56,7 @@ private:
eth::Client* m_client; eth::Client* m_client;
QByteArray m_peers;
QMutex m_guiLock; QMutex m_guiLock;
QTimer* m_refresh; QTimer* m_refresh;
QStringList m_servers; QStringList m_servers;

30
libethereum/PeerNetwork.cpp

@ -197,9 +197,7 @@ bool PeerSession::interpret(RLP const& _r)
for (unsigned i = 1; i < _r.itemCount(); ++i) for (unsigned i = 1; i < _r.itemCount(); ++i)
{ {
auto ep = bi::tcp::endpoint(bi::address_v4(_r[i][0].toArray<byte, 4>()), _r[i][1].toInt<short>()); auto ep = bi::tcp::endpoint(bi::address_v4(_r[i][0].toArray<byte, 4>()), _r[i][1].toInt<short>());
Public id; Public id = _r[i][2].toHash<Public>();
if (_r[i].itemCount() > 2)
id = _r[i][2].toHash<Public>();
clogS(NetAllDetail) << "Checking: " << ep << "(" << asHex(id.ref().cropped(0, 4)) << ")"; clogS(NetAllDetail) << "Checking: " << ep << "(" << asHex(id.ref().cropped(0, 4)) << ")";
@ -223,8 +221,8 @@ bool PeerSession::interpret(RLP const& _r)
for (auto i: m_server->m_incomingPeers) for (auto i: m_server->m_incomingPeers)
if (i.second == ep) if (i.second == ep)
goto CONTINUE; goto CONTINUE;
m_server->m_incomingPeers.insert(make_pair(id, ep)); m_server->m_incomingPeers[id] = ep;
clogS(NetMessageDetail) << "New peer: " << ep; clogS(NetMessageDetail) << "New peer: " << ep << "(" << id << ")";
CONTINUE:; CONTINUE:;
} }
break; break;
@ -970,3 +968,25 @@ void PeerServer::pingAll()
if (auto j = i.second.lock()) if (auto j = i.second.lock())
j->ping(); j->ping();
} }
bytes PeerServer::savePeers() const
{
RLPStream ret;
int n = 0;
for (auto& i: m_peers)
if (auto p = i.second.lock())
if (p->m_socket.is_open() && p->endpoint().port())
{
ret.appendList(3) << p->endpoint().address().to_v4().to_bytes() << p->endpoint().port() << p->m_id;
n++;
}
return RLPStream(n).appendRaw(ret.out(), n).out();
}
void PeerServer::restorePeers(bytesConstRef _b)
{
for (auto i: RLP(_b))
{
m_incomingPeers.insert(make_pair((Public)i[2], bi::tcp::endpoint(bi::address_v4(i[0].toArray<byte, 4>()), i[1].toInt<short>())));
}
}

7
libethereum/PeerNetwork.h

@ -111,8 +111,8 @@ private:
void sealAndSend(RLPStream& _s); void sealAndSend(RLPStream& _s);
void sendDestroy(bytes& _msg); void sendDestroy(bytes& _msg);
void send(bytesConstRef _msg); void send(bytesConstRef _msg);
PeerServer* m_server; PeerServer* m_server;
bi::tcp::socket m_socket; bi::tcp::socket m_socket;
std::array<byte, 65536> m_data; std::array<byte, 65536> m_data;
PeerInfo m_info; PeerInfo m_info;
@ -182,6 +182,9 @@ public:
/// Get the port we're listening on currently. /// Get the port we're listening on currently.
short listenPort() const { return m_public.port(); } short listenPort() const { return m_public.port(); }
bytes savePeers() const;
void restorePeers(bytesConstRef _b);
private: private:
void seal(bytes& _b); void seal(bytes& _b);
void populateAddresses(); void populateAddresses();
@ -208,7 +211,7 @@ private:
std::vector<bytes> m_incomingTransactions; std::vector<bytes> m_incomingTransactions;
std::vector<bytes> m_incomingBlocks; std::vector<bytes> m_incomingBlocks;
std::multimap<Public, bi::tcp::endpoint> m_incomingPeers; std::map<Public, bi::tcp::endpoint> m_incomingPeers;
h256 m_latestBlockSent; h256 m_latestBlockSent;
std::set<h256> m_transactionsSent; std::set<h256> m_transactionsSent;

Loading…
Cancel
Save