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

29
alethzero/MainWin.cpp

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

Loading…
Cancel
Save