Browse Source

style

cl-refactor
subtly 10 years ago
parent
commit
521bf5b384
  1. 30
      alethzero/Connect.cpp
  2. 37
      alethzero/Connect.h
  3. 29
      alethzero/MainWin.cpp
  4. 4
      libp2p/NodeTable.cpp

30
alethzero/Connect.cpp

@ -1,18 +1,18 @@
/* /*
This file is part of cpp-ethereum. This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful, cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @file Connect.cpp /** @file Connect.cpp
* @author Alex Leverington <nessence@gmail.com> * @author Alex Leverington <nessence@gmail.com>
@ -25,15 +25,15 @@
#include "ui_Connect.h" #include "ui_Connect.h"
Connect::Connect(QWidget *parent) : Connect::Connect(QWidget *parent) :
QDialog(parent), QDialog(parent),
ui(new Ui::Connect) ui(new Ui::Connect)
{ {
ui->setupUi(this); ui->setupUi(this);
} }
Connect::~Connect() Connect::~Connect()
{ {
delete ui; delete ui;
} }
void Connect::setEnvironment(QStringList const& _nodes) void Connect::setEnvironment(QStringList const& _nodes)

37
alethzero/Connect.h

@ -1,18 +1,18 @@
/* /*
This file is part of cpp-ethereum. This file is part of cpp-ethereum.
cpp-ethereum is free software: you can redistribute it and/or modify cpp-ethereum is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
cpp-ethereum is distributed in the hope that it will be useful, cpp-ethereum is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** @file Connect.h /** @file Connect.h
* @author Alex Leverington <nessence@gmail.com> * @author Alex Leverington <nessence@gmail.com>
@ -29,22 +29,23 @@ namespace dev { namespace p2p { class Host; } }
class Connect : public QDialog class Connect : public QDialog
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit Connect(QWidget *parent = 0); explicit Connect(QWidget* _parent = 0);
~Connect(); ~Connect();
void setEnvironment(QStringList const& _nodes); void setEnvironment(QStringList const& _nodes);
/// clear dialogue inputs
void reset(); void reset();
QString host(); // Form field values:
QString host();
QString nodeId(); QString nodeId();
bool required(); bool required();
private: private:
Ui::Connect *ui; Ui::Connect* ui;
}; };

29
alethzero/MainWin.cpp

@ -252,30 +252,30 @@ void Main::addNewId(QString _ids)
NetworkPreferences Main::netPrefs() const NetworkPreferences Main::netPrefs() const
{ {
auto listenip = ui->listenIP->text().toStdString(); auto listenIP = ui->listenIP->text().toStdString();
try try
{ {
listenip = bi::address::from_string(listenip).to_string(); listenIP = bi::address::from_string(listenIP).to_string();
} }
catch (...) catch (...)
{ {
listenip = ""; listenIP = "";
} }
auto publicip = ui->forcePublicIP->text().toStdString(); auto publicIP = ui->forcePublicIP->text().toStdString();
try try
{ {
publicip = bi::address::from_string(publicip).to_string(); publicIP = bi::address::from_string(publicIP).to_string();
} }
catch (...) catch (...)
{ {
publicip = ""; publicIP = "";
} }
if (isPublicAddress(publicip)) if (isPublicAddress(publicIP))
return NetworkPreferences(publicip, ui->listenIP->text().toStdString(), ui->port->value(), ui->upnp->isChecked()); return NetworkPreferences(publicIP, ui->listenIP->text().toStdString(), ui->port->value(), ui->upnp->isChecked());
else else
return NetworkPreferences(listenip, ui->port->value(), ui->upnp->isChecked()); return NetworkPreferences(listenIP, ui->port->value(), ui->upnp->isChecked());
} }
void Main::onKeysChanged() void Main::onKeysChanged()
@ -1790,21 +1790,20 @@ void Main::on_connect_triggered()
if (m_connect.exec() == QDialog::Accepted) if (m_connect.exec() == QDialog::Accepted)
{ {
bool required = m_connect.required(); bool required = m_connect.required();
string host(m_connect.host().toUtf8().constData()); string host(m_connect.host().toStdString());
NodeId nodeid; NodeId nodeID;
try try
{ {
string nstr(m_connect.nodeId().toUtf8().constData()); nodeID = NodeId(fromHex(m_connect.nodeId().toStdString()));
nodeid = NodeId(fromHex(nstr));
} }
catch (BadHexCharacter()) {} catch (BadHexCharacter()) {}
m_connect.reset(); m_connect.reset();
if (required) if (required)
web3()->requirePeer(nodeid, host); web3()->requirePeer(nodeID, host);
else else
web3()->addNode(nodeid, host); web3()->addNode(nodeID, host);
} }
} }

4
libp2p/NodeTable.cpp

@ -555,8 +555,8 @@ void NodeTable::doRefreshBuckets(boost::system::error_code const& _ec)
if (connected) if (connected)
{ {
NodeId randNodeId; NodeId randNodeId;
crypto::Nonce::get().ref().copyTo(randNodeId.ref().cropped(0,h256::size)); crypto::Nonce::get().ref().copyTo(randNodeId.ref().cropped(0, h256::size));
crypto::Nonce::get().ref().copyTo(randNodeId.ref().cropped(h256::size,h256::size)); crypto::Nonce::get().ref().copyTo(randNodeId.ref().cropped(h256::size, h256::size));
discover(randNodeId); discover(randNodeId);
} }

Loading…
Cancel
Save