git ssb

15+

ansuz / dnssb



Commit 46d16a94907516fbe8124c691d904a5b57916575

Factor out merging results

Merge flags also
cel committed on 11/26/2016, 6:16:45 PM
Parent: 7216c5147c617ec965b6bf02ee91da180a9d4cb7

Files changed

lib/query.jschanged
lib/query.jsView
@@ -9,9 +9,9 @@
99 && a.type === b.type
1010 && a.class === b.class);
1111 }
1212
13-function merge(into, from) {
13 +function mergeRecords(into, from) {
1414 if (from) from.filter(function (a) {
1515 return into.every(function (b) {
1616 return !isRecordEqual(a, b);
1717 })
@@ -19,8 +19,18 @@
1919 into.push(rec);
2020 });
2121 }
2222
23 +function mergeResults(into, from) {
24 + mergeRecords(into.additionals, from.additionals);
25 + mergeRecords(into.answers, from.answers);
26 + mergeRecords(into.authorities, from.authorities);
27 + mergeRecords(into.questions, from.questions);
28 + if (from.expires < into.expires) into.expires = from.expires;
29 + into.domainExists |= from.domainExists
30 + into.authoritative |= from.authoritative
31 +}
32 +
2333 Query.branches = function (sbot, name, type, _class, cb) {
2434 if (!_class) _class = "IN";
2535 var branches = [];
2636 Pull(Query.all(sbot),
@@ -214,13 +224,9 @@
214224
215225 function next(err, res) {
216226 if (err) return waiting = 0, cb(err);
217227
218- merge(result.additionals, res.additionals);
219- merge(result.answers, res.answers);
220- merge(result.authorities, res.authorities);
221- merge(result.questions, res.questions);
222- if (res.expires < result.expires) result.expires = res.expires;
228 + mergeResults(result, res)
223229
224230 // recurse on CNAMEs
225231 if (!isTransfer && question.type !== 'CNAME') {
226232 var stack2 = stack.concat(question)

Built with git-ssb-web