Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Commit

Permalink
voting power limit
Browse files Browse the repository at this point in the history
  • Loading branch information
mahdiyari committed Feb 2, 2018
1 parent 170b8c7 commit cac04ad
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions nodejs/fanbase.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,22 @@ setInterval(function(){
},30000);
},100000);


// Check voting power limit
function checkpowerlimit(voter,author,permlink,weight){
con.query('SELECT `current_power`,`limit_power` FROM `users` WHERE `user`="'+voter+'"', function (error, results, fields) {
for(i in results){
var powernow = results[i].current_power;
var powerlimit = results[i].limit_power;
if(powernow > powerlimit){
upvote(voter,author,permlink,weight);
}else{
console.log('power is under limit user '+voter);
}
}
});

return 1;
}
// Upvote function - included 0 seconds delay!
var delay = 0;
function upvote(voter,author,permlink,weight){
Expand Down Expand Up @@ -116,7 +131,7 @@ var fanupvote = function(author,permlink){
});
console.log('fan to delay');
}else{
upvote(follower,author,permlink,weight);
checkpowerlimit(follower,author,permlink,weight);
console.log('fan to up');
}
}
Expand Down

0 comments on commit cac04ad

Please sign in to comment.