insight-bitcore-api
Version:
An open-source bitcoin blockchain API. The Insight API provides you with a convenient, powerful and simple way to query and broadcast data on the bitcoin network and build your own services with it.
33 lines (26 loc) • 734 B
JavaScript
;
var imports = require('soop').imports();
var fs = require('fs');
var buffertools = require('buffertools');
var db = imports.db || JSON.parse( fs.readFileSync(imports.poolMatchFile || './poolMatchFile.json'));
var PoolMatch = function() {
var self = this;
self.strings = {};
db.forEach(function(pool) {
pool.searchStrings.forEach(function(s) {
self.strings[s] = {
poolName: pool.poolName,
url: pool.url
};
});
});
};
PoolMatch.prototype.match = function(buffer) {
var self = this;
for(var k in self.strings) {
if (buffertools.indexOf(buffer, k) >= 0) {
return self.strings[k];
}
}
};
module.exports = require('soop')(PoolMatch);