2014-05-23 18:14:06 +00:00
|
|
|
var Constants = require('./constants.js');
|
2014-03-18 16:29:20 +00:00
|
|
|
|
2014-06-02 20:44:20 +00:00
|
|
|
function SuperNode(options) {
|
2014-05-23 18:14:06 +00:00
|
|
|
var now = Date.now();
|
2014-03-18 16:29:20 +00:00
|
|
|
|
2014-05-23 18:14:06 +00:00
|
|
|
this.id = Constants.SUPER_NODE_ID;
|
2018-05-24 18:32:27 +00:00
|
|
|
this.type = Constants.NODE_TYPE_META;
|
2014-06-02 20:44:20 +00:00
|
|
|
this.atime = options.atime || now;
|
|
|
|
this.ctime = options.ctime || now;
|
|
|
|
this.mtime = options.mtime || now;
|
|
|
|
// root node id (randomly generated)
|
|
|
|
this.rnode = options.rnode;
|
|
|
|
}
|
|
|
|
|
|
|
|
SuperNode.create = function(options, callback) {
|
|
|
|
options.guid(function(err, rnode) {
|
|
|
|
if(err) {
|
|
|
|
callback(err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
options.rnode = options.rnode || rnode;
|
|
|
|
callback(null, new SuperNode(options));
|
|
|
|
});
|
2014-05-23 18:14:06 +00:00
|
|
|
};
|
2014-06-02 20:44:20 +00:00
|
|
|
|
|
|
|
module.exports = SuperNode;
|