Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "closer-but-not-exact" responses to our DHT knowledge #17

Open
tristanls opened this issue Mar 2, 2014 · 1 comment
Open

Add "closer-but-not-exact" responses to our DHT knowledge #17

tristanls opened this issue Mar 2, 2014 · 1 comment

Comments

@tristanls
Copy link
Owner

As @skeggse suggested in #15, it may be useful/correct when dealing with responses that are not the exact match of the node we are looking for (those that point to closer nodes to ask next) to add these intermediate nodes to our knowledge of the DHT.

@tristanls
Copy link
Owner Author

More precisely, instead of only checking "closer-but-not-exact" responses against locally registered contacts like we do here index.js#L128:

if (Array.isArray(response)) {
    // arbiter "closer" responses against locally registered contacts
    response.forEach(function (res) {
        if (self.kBuckets[res.id]) {
            self.kBuckets[res.id].contact =
                self.arbiter(self.kBuckets[res.id].contact, res);
        }
    });

also add them to our local DHT knowledge:

if (Array.isArray(response)) {
    // arbiter "closer" responses against locally registered contacts
    response.forEach(function (res) {
        self.add(res); // add() handlers arbitration on its own
    });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant