diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-07-16 17:42:47 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-07-16 17:42:47 -0700 |
commit | 0db7c94c9004ac488b6163905d80f7515141d9c6 (patch) | |
tree | 5106f4247b1413a42363f955bf56972a0bb90b0a /controller | |
parent | 99969b186b3a078fb5cc8d3bfa004ebf9fc6d95a (diff) | |
download | infinitytier-0db7c94c9004ac488b6163905d80f7515141d9c6.tar.gz infinitytier-0db7c94c9004ac488b6163905d80f7515141d9c6.zip |
Add memberRevision stuff to JSON output, and update docs.
Diffstat (limited to 'controller')
-rw-r--r-- | controller/SqliteNetworkController.cpp | 10 | ||||
-rw-r--r-- | controller/schema.sql | 2 | ||||
-rw-r--r-- | controller/schema.sql.c | 2 |
3 files changed, 9 insertions, 5 deletions
diff --git a/controller/SqliteNetworkController.cpp b/controller/SqliteNetworkController.cpp index c9535fef..cc53d4d5 100644 --- a/controller/SqliteNetworkController.cpp +++ b/controller/SqliteNetworkController.cpp @@ -190,7 +190,7 @@ SqliteNetworkController::SqliteNetworkController(const char *dbPath) : /* Member */ ||(sqlite3_prepare_v2(_db,"SELECT rowid,authorized,activeBridge FROM Member WHERE networkId = ? AND nodeId = ?",-1,&_sGetMember,(const char **)0) != SQLITE_OK) - ||(sqlite3_prepare_v2(_db,"SELECT m.authorized,m.activeBridge,n.identity FROM Member AS m JOIN Node AS n ON n.id = m.nodeId WHERE m.networkId = ? AND m.nodeId = ?",-1,&_sGetMember2,(const char **)0) != SQLITE_OK) + ||(sqlite3_prepare_v2(_db,"SELECT m.authorized,m.activeBridge,m.memberRevision,n.identity FROM Member AS m JOIN Node AS n ON n.id = m.nodeId WHERE m.networkId = ? AND m.nodeId = ?",-1,&_sGetMember2,(const char **)0) != SQLITE_OK) ||(sqlite3_prepare_v2(_db,"INSERT INTO Member (networkId,nodeId,authorized,activeBridge,memberRevision) VALUES (?,?,?,0,(SELECT memberRevisionCounter FROM Network WHERE id = ?))",-1,&_sCreateMember,(const char **)0) != SQLITE_OK) ||(sqlite3_prepare_v2(_db,"SELECT nodeId FROM Member WHERE networkId = ? AND activeBridge > 0 AND authorized > 0",-1,&_sGetActiveBridges,(const char **)0) != SQLITE_OK) ||(sqlite3_prepare_v2(_db,"SELECT m.nodeId FROM Member AS m WHERE m.networkId = ? ORDER BY m.nodeId ASC",-1,&_sListNetworkMembers,(const char **)0) != SQLITE_OK) @@ -1256,13 +1256,15 @@ unsigned int SqliteNetworkController::_doCPGet( "\t\"address\": \"%s\",\n" "\t\"authorized\": %s,\n" "\t\"activeBridge\": %s,\n" + "\t\"memberRevision\": %llu,\n" "\t\"identity\": \"%s\",\n" "\t\"ipAssignments\": [", nwids, addrs, (sqlite3_column_int(_sGetMember2,0) > 0) ? "true" : "false", (sqlite3_column_int(_sGetMember2,1) > 0) ? "true" : "false", - _jsonEscape((const char *)sqlite3_column_text(_sGetMember2,2)).c_str()); + (unsigned long long)sqlite3_column_int64(_sGetMember2,2), + _jsonEscape((const char *)sqlite3_column_text(_sGetMember2,3)).c_str()); responseBody = json; sqlite3_reset(_sGetIpAssignmentsForNode2); @@ -1359,6 +1361,7 @@ unsigned int SqliteNetworkController::_doCPGet( "\t\"multicastLimit\": %d,\n" "\t\"creationTime\": %llu,\n" "\t\"revision\": %llu,\n" + "\t\"memberRevisionCounter\": %llu,\n" "\t\"members\": [", nwids, _jsonEscape((const char *)sqlite3_column_text(_sGetNetworkById,0)).c_str(), @@ -1369,7 +1372,8 @@ unsigned int SqliteNetworkController::_doCPGet( _jsonEscape((const char *)sqlite3_column_text(_sGetNetworkById,5)).c_str(), sqlite3_column_int(_sGetNetworkById,6), (unsigned long long)sqlite3_column_int64(_sGetNetworkById,7), - (unsigned long long)sqlite3_column_int64(_sGetNetworkById,8)); + (unsigned long long)sqlite3_column_int64(_sGetNetworkById,8), + (unsigned long long)sqlite3_column_int64(_sGetNetworkById,9)); responseBody = json; sqlite3_reset(_sListNetworkMembers); diff --git a/controller/schema.sql b/controller/schema.sql index ea816b95..c3eec234 100644 --- a/controller/schema.sql +++ b/controller/schema.sql @@ -58,7 +58,7 @@ CREATE TABLE Member ( nodeId char(10) NOT NULL REFERENCES Node(id) ON DELETE CASCADE, authorized integer NOT NULL DEFAULT(0), activeBridge integer NOT NULL DEFAULT(0), - memberRevision integer NOT NULL DEFAULT(0) + memberRevision integer NOT NULL DEFAULT(0), PRIMARY KEY (networkId, nodeId) ); diff --git a/controller/schema.sql.c b/controller/schema.sql.c index 7f1342a8..78123db4 100644 --- a/controller/schema.sql.c +++ b/controller/schema.sql.c @@ -59,7 +59,7 @@ " nodeId char(10) NOT NULL REFERENCES Node(id) ON DELETE CASCADE,\n"\ " authorized integer NOT NULL DEFAULT(0),\n"\ " activeBridge integer NOT NULL DEFAULT(0),\n"\ -" memberRevision integer NOT NULL DEFAULT(0)\n"\ +" memberRevision integer NOT NULL DEFAULT(0),\n"\ " PRIMARY KEY (networkId, nodeId)\n"\ ");\n"\ "\n"\ |