Remove lastModified field in config which literally nothing uses anywhere, and prevent some unnecessary writes.

This commit is contained in:
Adam Ierymenko 2017-04-28 19:58:21 -07:00
parent d69bc4fb5e
commit a9ce773584
2 changed files with 8 additions and 17 deletions

View File

@ -715,20 +715,18 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpPOST(
member["address"] = addrs; // legacy member["address"] = addrs; // legacy
member["nwid"] = nwids; member["nwid"] = nwids;
_removeMemberNonPersistedFields(member);
if (member != origMember) { if (member != origMember) {
member["lastModified"] = now;
json &revj = member["revision"]; json &revj = member["revision"];
member["revision"] = (revj.is_number() ? ((uint64_t)revj + 1ULL) : 1ULL); member["revision"] = (revj.is_number() ? ((uint64_t)revj + 1ULL) : 1ULL);
_removeMemberNonPersistedFields(member);
_db.saveNetworkMember(nwid,address,member); _db.saveNetworkMember(nwid,address,member);
_pushMemberUpdate(now,nwid,member); _pushMemberUpdate(now,nwid,member);
} }
// Add non-persisted fields _addMemberNonPersistedFields(member,now);
member["clock"] = now;
responseBody = OSUtils::jsonDump(member); responseBody = OSUtils::jsonDump(member);
responseContentType = "application/json"; responseContentType = "application/json";
return 200; return 200;
} else if ((path.size() == 3)&&(path[2] == "test")) { } else if ((path.size() == 3)&&(path[2] == "test")) {
@ -1018,11 +1016,10 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpPOST(
network["id"] = nwids; network["id"] = nwids;
network["nwid"] = nwids; // legacy network["nwid"] = nwids; // legacy
_removeNetworkNonPersistedFields(network);
if (network != origNetwork) { if (network != origNetwork) {
json &revj = network["revision"]; json &revj = network["revision"];
network["revision"] = (revj.is_number() ? ((uint64_t)revj + 1ULL) : 1ULL); network["revision"] = (revj.is_number() ? ((uint64_t)revj + 1ULL) : 1ULL);
network["lastModified"] = now;
_removeNetworkNonPersistedFields(network);
_db.saveNetwork(nwid,network); _db.saveNetwork(nwid,network);
// Send an update to all members of the network // Send an update to all members of the network
@ -1349,11 +1346,9 @@ void EmbeddedNetworkController::_request(
// If they are not authorized, STOP! // If they are not authorized, STOP!
if (!authorizedBy) { if (!authorizedBy) {
if (origMember != member) { _removeMemberNonPersistedFields(member);
member["lastModified"] = now; if (origMember != member)
_removeMemberNonPersistedFields(member);
_db.saveNetworkMember(nwid,identity.address().toInt(),member); _db.saveNetworkMember(nwid,identity.address().toInt(),member);
}
_sender->ncSendError(nwid,requestPacketId,identity.address(),NetworkController::NC_ERROR_ACCESS_DENIED); _sender->ncSendError(nwid,requestPacketId,identity.address(),NetworkController::NC_ERROR_ACCESS_DENIED);
return; return;
} }
@ -1700,11 +1695,9 @@ void EmbeddedNetworkController::_request(
return; return;
} }
if (member != origMember) { _removeMemberNonPersistedFields(member);
member["lastModified"] = now; if (member != origMember)
_removeMemberNonPersistedFields(member);
_db.saveNetworkMember(nwid,identity.address().toInt(),member); _db.saveNetworkMember(nwid,identity.address().toInt(),member);
}
_sender->ncSendConfig(nwid,requestPacketId,identity.address(),*(nc.get()),metaData.getUI(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_VERSION,0) < 6); _sender->ncSendConfig(nwid,requestPacketId,identity.address(),*(nc.get()),metaData.getUI(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_VERSION,0) < 6);
} }

View File

@ -95,7 +95,6 @@ async.series([function(nextStep) {
creationTime: parseInt(row.creationTime)||0, creationTime: parseInt(row.creationTime)||0,
enableBroadcast: !!row.enableBroadcast, enableBroadcast: !!row.enableBroadcast,
ipAssignmentPools: [], ipAssignmentPools: [],
lastModified: Date.now(),
multicastLimit: row.multicastLimit||32, multicastLimit: row.multicastLimit||32,
name: row.name||'', name: row.name||'',
private: !!row.private, private: !!row.private,
@ -177,7 +176,6 @@ async.series([function(nextStep) {
ipAssignments: [], ipAssignments: [],
lastAuthorizedTime: (row.authorized) ? Date.now() : 0, lastAuthorizedTime: (row.authorized) ? Date.now() : 0,
lastDeauthorizedTime: (row.authorized) ? 0 : Date.now(), lastDeauthorizedTime: (row.authorized) ? 0 : Date.now(),
lastModified: Date.now(),
lastRequestMetaData: '', lastRequestMetaData: '',
noAutoAssignIps: false, noAutoAssignIps: false,
nwid: row.networkId, nwid: row.networkId,