Factor out methods for index manipulation

This commit is contained in:
Tony Garnock-Jones 2018-11-11 13:58:00 +00:00
parent e55e5155b7
commit 76678f7b27
1 changed files with 11 additions and 3 deletions

View File

@ -210,7 +210,7 @@ Dataspace.prototype.applyPatch = function (ac, delta) {
delta.forEach((count, a) => {
if (a !== void 0) {
if (count > 0) {
this.index.adjustAssertion(a, count);
this.adjustIndex(a, count);
} else {
removals.push([count, a]);
}
@ -218,10 +218,18 @@ Dataspace.prototype.applyPatch = function (ac, delta) {
}
});
removals.forEach(([count, a]) => {
this.index.adjustAssertion(a, count);
this.adjustIndex(a, count);
});
};
Dataspace.prototype.sendMessage = function (m) {
this.index.sendMessage(m);
};
Dataspace.prototype.adjustIndex = function (a, count) {
return this.index.adjustAssertion(a, count);
};
Dataspace.prototype.subscribe = function (handler) {
this.index.addHandler(handler, handler.callback);
};
@ -383,7 +391,7 @@ function Message(body) {
Message.prototype.perform = function (ds, ac) {
if (this.body !== void 0) {
ds.index.sendMessage(Immutable.fromJS(this.body));
ds.sendMessage(Immutable.fromJS(this.body));
}
};