summaryrefslogtreecommitdiffstats
path: root/pica-client/nodes.cpp
diff options
context:
space:
mode:
authorAnton <anton@picapica>2017-12-01 22:16:24 +0400
committerAnton <anton@picapica>2017-12-01 22:16:24 +0400
commit0f726c30f5f11990d325bc5e55015c42c80cd9d2 (patch)
treef8c9b83cc440dd3a2f43285dc35199435f6e2701 /pica-client/nodes.cpp
parentac041927bc0c82e33acaa9e15fd46ecca0b77172 (diff)
downloadpica-pica-0f726c30f5f11990d325bc5e55015c42c80cd9d2.tar.gz
pica-pica-0f726c30f5f11990d325bc5e55015c42c80cd9d2.zip
fixed code style on all source files (*.c *.cpp *.h) using astyle --style=allman --lineend=linux --indent=tab --pad-oper
Diffstat (limited to 'pica-client/nodes.cpp')
-rw-r--r--pica-client/nodes.cpp76
1 files changed, 38 insertions, 38 deletions
diff --git a/pica-client/nodes.cpp b/pica-client/nodes.cpp
index eb8bfcc..93ae5e2 100644
--- a/pica-client/nodes.cpp
+++ b/pica-client/nodes.cpp
@@ -2,51 +2,51 @@
Nodes::Nodes(QString storage)
{
- dbconn=QSqlDatabase::addDatabase("QSQLITE");
- dbconn.setDatabaseName(storage);
-
- if (!dbconn.open())
- {
- lasterr=dbconn.lastError();
- return;
- }
+ dbconn = QSqlDatabase::addDatabase("QSQLITE");
+ dbconn.setDatabaseName(storage);
+
+ if (!dbconn.open())
+ {
+ lasterr = dbconn.lastError();
+ return;
+ }
//check if table nodes exists
}
void Nodes::Add(NodeRecord &n)
{
- QSqlQuery query;
+ QSqlQuery query;
- query.prepare("insert into nodes (address, port, last_active, inactive_count) values (:addr, :port, strftime('%s','now'), 0)");
- query.bindValue(":addr",n.address);
- query.bindValue(":port",n.port);
- query.exec();
+ query.prepare("insert into nodes (address, port, last_active, inactive_count) values (:addr, :port, strftime('%s','now'), 0)");
+ query.bindValue(":addr", n.address);
+ query.bindValue(":port", n.port);
+ query.exec();
- lasterr=query.lastError();
+ lasterr = query.lastError();
}
QList<Nodes::NodeRecord> Nodes::GetNodes()
{
- QList<NodeRecord> L;
- NodeRecord r;
- QSqlQuery query;
+ QList<NodeRecord> L;
+ NodeRecord r;
+ QSqlQuery query;
- query.setForwardOnly(true);
- query.exec("select address, port from nodes order by inactive_count asc, last_active desc");
- lasterr=query.lastError();
+ query.setForwardOnly(true);
+ query.exec("select address, port from nodes order by inactive_count asc, last_active desc");
+ lasterr = query.lastError();
- if (lasterr.isValid())
- return L;
+ if (lasterr.isValid())
+ return L;
- while(query.next())
- {
- r.address =query.value(0).toString();
- r.port =query.value(1).toUInt();
+ while(query.next())
+ {
+ r.address = query.value(0).toString();
+ r.port = query.value(1).toUInt();
- L<<r;
- }
+ L << r;
+ }
- return L;
+ return L;
}
void Nodes::MakeClean()
@@ -56,18 +56,18 @@ void Nodes::MakeClean()
void Nodes::UpdateStatus(NodeRecord &n, bool alive)
{
- QSqlQuery query;
+ QSqlQuery query;
- if (alive)
- query.prepare("update nodes set last_active = strftime('%s','now'), inactive_count = 0 where address = :addr and port = :port");
- else
- query.prepare("update nodes set inactive_count = inactive_count + 1 where address = :addr and port = :port");
+ if (alive)
+ query.prepare("update nodes set last_active = strftime('%s','now'), inactive_count = 0 where address = :addr and port = :port");
+ else
+ query.prepare("update nodes set inactive_count = inactive_count + 1 where address = :addr and port = :port");
- query.bindValue(":addr",n.address);
- query.bindValue(":port",n.port);
- query.exec();
+ query.bindValue(":addr", n.address);
+ query.bindValue(":port", n.port);
+ query.exec();
- lasterr=query.lastError();
+ lasterr = query.lastError();
}