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

WIP: Peers purge old and add new #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ module.exports = {
});
},
delete_peer: function(params, cb) {
Peers.deleteOne(params, function(err){
Peers.remove(params, function(err){
});
}
};
11 changes: 6 additions & 5 deletions scripts/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ mongoose.connect(dbString, function(err) {
livepeers[i] = address;
db.find_peer(address, function(peer) {
if (peer) {
console.log('Live version is: ', semver); //remove this if you'd like
//console.log('Live version is: ', semver); //remove this if you'd like
for(i=0; i<peer.length; i++){
// cmp(a,b)
// result 1 = a is greater than b
Expand All @@ -53,16 +53,17 @@ mongoose.connect(dbString, function(err) {
loop.next();
});
});
console.log('Delete the db version:', peer[i].version.split(":")[1]); //remove
//console.log('Delete the db version:', peer[i].version.split(":")[1]); //remove
} else if(cmp(peer[i].version.split(":")[1], semver) == 0){
//console.log('Do nothing, they\'re the same');
} else {
//db.delete_peer({_id:peer[i]._id}); //not sure how this should be handled
console.log('This should never occur, Live Version:', semver, " Is less than:", peer[i].version.split(":")[1]); //remove
//console.log('This should never occur, Live Version:', semver, " Is less than:", peer[i].version.split(":")[1]); //remove
}
}
loop.next();
} else {
request({uri: 'http://api.ipstack.com/' + address + '?access_key=' + settings.iplookup.apikey, json: true}, function (error, response, geo) {
request({uri: 'http://api.ipstack.com/' + address + '?access_key=' + settings.peers.ipstack_api_key, json: true}, function (error, response, geo) {
db.create_peer({
address: address,
protocol: body[i].version,
Expand All @@ -82,7 +83,7 @@ mongoose.connect(dbString, function(err) {
db.delete_peer({address:peers[i].address});
}
}
console.log('done');
//console.log('done');
exit();
});
});
Expand Down