Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var redis = require('redis');
var client = redis.createClient();
var pullNotifications = function() {
// if notification in list rpop it else block until one is available; timeout=0;
client.brpop('_bitcoin_notifications_', '_bitcoin_notifications_', 0, function(e, data) {
if(!data.length) return;
data = JSON.parse(data[1]);
switch(data.type) {
case "block":
// do something
console.log('new block!');
console.log(data);
break;
case "transaction":
// do something
console.log('new transaction!');
console.log(data);
break;
}
pullNotifications();
});
};
pullNotifications();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.