intchains_ibctminer
Version:
```js const IntMiner = require('./src'); const Debug = require('./src/log')(); const fs = require('fs'); const COMP = '[SIPC]';
47 lines (42 loc) • 1.07 kB
JavaScript
const scryptApi = require('./scryptApi');
const EventEmitter = require('events');
const Debug = require('../log')();
const COMP = '[algo]';
const algorithms = [
{
name: 'scrypt',
api: scryptApi
}
];
class algoApi extends EventEmitter {
constructor({
name
}) {
super();
var _this = this;
_this.name = name;
_this.algorithm = this.GetAlgorithmApi(_this.name);
if (!_this.algorithm) {
_this.emit('error', 'Get algorithm Error');
}
return _this;
}
GetAlgorithmApi(name) {
var algo = null;
algorithms.forEach(function (algorithm, index) {
if (algorithm.name === name) {
algo = algorithm;
}
})
return algo ? algo.api() : null;
}
getAlgoName() {
return this.algorithm ? this.algorithm.getAlgoName() : null;
}
genHash(data, length, varity) {
return this.algorithm ? this.algorithm.genHash(data, length, varity) : null;
}
};
module.exports = function RunAlgoApi(options = {}) {
return new algoApi(options);
};