This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.publish 'order_book', (pairId) -> | |
return unless pairId | |
selector = | |
pairId: pairId | |
complete: false | |
cancelled: false | |
bids = {} | |
asks = {} | |
obs = Orders.find(selector).observe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Queue = new Meteor.Collection 'queue' | |
Meteor.startup -> | |
Meteor._processQueue = -> | |
if Meteor._queueProcessing ||= false | |
Meteor.setTimeout Meteor._processQueue, 100 | |
return | |
Meteor._queueProcessing = true | |
qsize = Meteor._queue.length | |
qdone = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.publish 'order_book', (pairId) -> | |
return unless pairId | |
selector = | |
pairId: pairId | |
complete: false | |
cancelled: false | |
bids = {} | |
asks = {} | |
round = (amount, precision = 8) -> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Workers.fetchHashrates = (curr) -> | |
hRates = Meteor._mining.getWorkerHashrates(curr.miningTable, curr.hashrateInterval, curr.shareDiff) | |
setHashrate = (userId, name, wrkName, hashrate) -> | |
sel = | |
userId: userId | |
wrkName: wrkName | |
currId: curr._id | |
id = Hashrates.findOne(sel) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetchHrates: (curr) -> | |
setHashrate = (userId, name, wrkName, hashrate) -> | |
sel = | |
userId: userId | |
wrkName: wrkName | |
currId: curr._id | |
if id = Hashrates.findOne(sel, {fields: {_id: 1}})?._id | |
Hashrates.update id, $set: {hashrate: hashrate, name: name} | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setHrates = function (curr) { | |
console.log(curr.name, hRates); | |
setHashrate = function(userId, name, wrkName, hashrate) { | |
var id, sel, _ref; | |
sel = { | |
userId: userId, | |
wrkName: wrkName, | |
currId: curr._id | |
}; | |
if (id = (_ref = Hashrates.findOne(sel, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Mysql = Npm.require 'mysql' | |
Future = Npm.require 'fibers/future' | |
class Mining | |
constructor: (host, port, dbname, dbuser, dbpass) -> | |
@dbSettings = | |
host: host | |
port: port | |
user: dbuser | |
password: dbpass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Workers.fetchHashrates = (curr) -> | |
Meteor._mining.getWorkerHashrates curr.miningTable, curr.hashrateInterval, curr.shareDiff, (hRates) -> | |
console.log curr.name, hRates | |
setHashrate = (userId, name, wrkName, hashrate) -> | |
sel = | |
userId: userId | |
wrkName: wrkName | |
currId: curr._id | |
if id = Hashrates.findOne(sel, {fields: {_id: 1}})?._id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.processCurrs = -> | |
Currencies.find().forEach (curr) -> | |
console.log "Processing", curr.name | |
Meteor.setTimeout -> curr.client().processTransactions() | |
Meteor.setInterval Meteor.processCurrs, 30*1000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.startup -> | |
Meteor.publish 'hashrates', -> | |
return unless @userId | |
Hashrates.find({userId: @userId}) | |
Meteor.publish 'top_hrates', (currId) -> | |
sel = { wrkName: '__total__', hashrate: {$gt: 0} } | |
sel.currId = currId if currId | |
opt = | |
sort: { hashrate: -1 } |