Possible error in the code expression of vector clocks (chapter3)
Closed this issue · 1 comments
Freeman97 commented
Sorry for my bad English. I think there is something wrong with the code of merging two vector clocks:
VectorClock.prototype.merge = function(other) {
var result = {}, last,
a = this.value,
b = other.value;
// This filters out duplicate keys in the hash
// But why join b and the key of a?
(Object.keys(a)
.concat(b))
.sort()
.filter(function(key) {
var isDuplicate = (key == last);
last = key;
return !isDuplicate;
}).forEach(function(key) {
result[key] = Math.max(a[key] || 0, b[key] || 0);
});
this.value = result;
};
The code join the key of a and b, but not the key of b.
Freeman97 commented
Sorry for not reading the pull request : (