class LogicalClock {
|
public:
|
...
|
|
// sets new time if the newTime > _clusterTime and the newTime passes validation.
|
// Return OK if time is updated
|
// Returns SignatureDoesNotMatch on signature mismatch.
|
Status advanceClusterTime(OperationContext* txn, SignedLogicalTime newTime) {
|
// TODO: grab mutex here
|
|
if (_lastLogicalTime.getTime() >= newTime.getTime()) {
|
return Status::OK();
|
}
|
|
if (!passesRateLimiter(newTime)) {
|
return {ErrorCodes::CannotAdvanceLogicalClock, ""};
|
}
|
|
if (autoOn) {
|
if (!hasEnoughPrivilege(txn)) {
|
auto mySignature = _hmacService->sign(newTime.getTime().serialize());
|
|
if (mySignature != newTime.getSignature()) {
|
return {ErrorCodes::SignatureDoesNotMatch, ""};
|
}
|
}
|
}
|
|
_lastLogicalTime = std::move(newTime);
|
}
|
}
|