Advertisement
Guest User

Untitled

a guest
Jul 28th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. swarmCollection.find({swarmID : info.swarmID}, function(err, swarm){
  2.             if(!err){
  3.               console.log("BEFORE FOREACH");
  4.               swarm.forEach(function(peer){
  5.                 console.log("In FOREACH");
  6.                 peerList.push(peer._id);
  7.                 console.log(peer._id);
  8.                 //console.log(peer.SwarmConn);
  9.               })
  10.             }else{
  11.               console.log(err);
  12.             }
  13.           });
  14.  
  15.           console.log(peerList + "PEEERLIST");
  16.           for(i = 0; i < 2; i++){
  17.             var item = peerList[Math.floor(Math.random()*peerList.length)];
  18.             swarmCollection.update({_id:info._id},{$addToSet:{SwarmConn : item}}, function(err){
  19.               if(!err){
  20.                 console.log("UPDATED SWARM CONN");
  21.               }else{
  22.                 console.log(err);
  23.               }
  24.             });
  25.           }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement