bitcore-node-zcash/lib/service.js

92 lines
1.8 KiB
JavaScript
Raw Normal View History

2015-07-21 13:59:08 -07:00
'use strict';
2015-08-31 06:00:00 -07:00
var util = require('util');
var EventEmitter = require('events').EventEmitter;
2015-08-31 06:00:00 -07:00
var Service = function(options) {
2015-08-31 06:00:00 -07:00
EventEmitter.call(this);
this.node = options.node;
2015-09-03 13:07:35 -07:00
this.name = options.name;
2015-07-21 13:59:08 -07:00
};
2015-08-31 06:00:00 -07:00
util.inherits(Service, EventEmitter);
2015-08-31 06:00:00 -07:00
2015-08-27 13:09:27 -07:00
/**
2015-08-31 06:00:00 -07:00
* Describes the dependencies that should be loaded before this service.
2015-08-27 13:09:27 -07:00
*/
2015-08-31 06:00:00 -07:00
Service.dependencies = [];
2015-08-27 13:09:27 -07:00
2015-07-23 13:52:22 -07:00
/**
* blockHandler
* @param {Block} block - the block being added or removed from the chain
* @param {Boolean} add - whether the block is being added or removed
* @param {Function} callback - call with the leveldb database operations to perform
*/
2015-08-31 06:00:00 -07:00
Service.prototype.blockHandler = function(block, add, callback) {
2015-07-21 13:59:08 -07:00
// implement in the child class
setImmediate(function() {
callback(null, []);
});
2015-07-21 13:59:08 -07:00
};
2015-07-29 14:22:34 -07:00
/**
* the bus events available for subscription
* @return {Array} an array of event info
*/
2015-08-31 06:00:00 -07:00
Service.prototype.getPublishEvents = function() {
2015-07-29 14:22:34 -07:00
// Example:
// return [
// ['eventname', this, this.subscribeEvent, this.unsubscribeEvent],
// ];
return [];
};
2015-07-23 13:52:22 -07:00
/**
* the API methods to expose
* @return {Array} return array of methods
*/
2015-08-31 06:00:00 -07:00
Service.prototype.getAPIMethods = function() {
2015-07-21 13:59:08 -07:00
// Example:
// return [
// ['getData', this, this.getData, 1]
// ];
return [];
};
// Example:
2015-08-31 06:00:00 -07:00
// Service.prototype.getData = function(arg1, callback) {
2015-07-21 13:59:08 -07:00
//
// };
/**
* Function which is called when module is first initialized
*/
2015-08-31 06:00:00 -07:00
Service.prototype.start = function(done) {
2015-08-27 13:09:27 -07:00
setImmediate(done);
2015-08-20 14:50:14 -07:00
};
/**
* Function to be called when bitcore-node is stopped
*/
2015-08-31 06:00:00 -07:00
Service.prototype.stop = function(done) {
2015-08-27 13:09:27 -07:00
setImmediate(done);
2015-08-20 14:50:14 -07:00
};
/**
* Setup express routes
* @param {Express} app
*/
Service.prototype.setupRoutes = function(app) {
// Setup express routes here
};
2015-09-03 13:07:35 -07:00
Service.prototype.getRoutePrefix = function() {
return this.name;
};
2015-08-31 06:00:00 -07:00
module.exports = Service;