Skip to content

Commit

Permalink
Merge pull request #9 from WaleedAshraf/blockchain
Browse files Browse the repository at this point in the history
Blockchain
  • Loading branch information
WaleedAshraf committed Aug 25, 2015
2 parents 2b4d064 + 8e41381 commit 0870bea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/blockchain.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var WebSocket = require('ws');
var ws = new WebSocket('wss://ws.chain.com/v2/notifications');
module.exports.blockchain = ws;
2 changes: 2 additions & 0 deletions worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ Sails.load(function(err, sails) {
var market = require('./worker/market.js');
// push continuous rate updates to redis
market.contRate();
var trans = require('./worker/transactions.js');
trans.trans();
});
12 changes: 12 additions & 0 deletions worker/transactions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var ws = sails.config.blockchain;
module.exports.trans = function(){
var log = sails.log;
ws.on('open', function() {
ws.send(JSON.stringify({type: 'new-transaction', block_chain: 'bitcoin'}));
});
ws.on('message', function(ev) {
var x = JSON.parse(ev);
log.silly('New Transaction',x);
});

};

0 comments on commit 0870bea

Please sign in to comment.