Represents a network.
@alias module:protocol.Network
@constructor
@param {Object|NetworkType} options - See {@link module:network}.
965035
function Network(options) {
  if (!(this instanceof Network))
    return new Network(options);

  assert(!Network[options.type], 'Cannot create two networks.');

  this.type = options.type;
  this.seeds = options.seeds;
  this.magic = options.magic;
  this.port = options.port;
  this.checkpointMap = options.checkpointMap;
  this.lastCheckpoint = options.lastCheckpoint;
  this.checkpoints = [];
  this.halvingInterval = options.halvingInterval;
  this.genesis = options.genesis;
  this.genesisBlock = options.genesisBlock;
  this.pow = options.pow;
  this.block = options.block;
  this.bip30 = options.bip30;
  this.activationThreshold = options.activationThreshold;
  this.minerWindow = options.minerWindow;
  this.deployments = options.deployments;
  this.deploys = options.deploys;
  this.unknownBits = ~consensus.VERSION_TOP_MASK;
  this.keyPrefix = options.keyPrefix;
  this.addressPrefix = options.addressPrefix;
  this.requireStandard = options.requireStandard;
  this.rpcPort = options.rpcPort;
  this.minRelay = options.minRelay;
  this.feeRate = options.feeRate;
  this.maxFeeRate = options.maxFeeRate;
  this.selfConnect = options.selfConnect;
  this.requestMempool = options.requestMempool;
  this.time = new TimeData();

  this._init();
}
589084
function handleConnection(self, options) {
	if (TRACE)	console.log('Connected to ' + options.host + ':' + options.port)
    	//self.socket = socket;
	self.emit("connect");
}
1299123
function Wire(options) {
  if (!(this instanceof Wire)) return new Wire(options);

  var opts = options || {};

  this.__co = opts.co || require('co');
  this.__p = opts.p || Promise;

  this.__hooks          = {};
  this.__handlers       = [];
  this.__sortedCache    = [];
  this.__knownChannels  = {};
  this.__skips          = {};
}
497695
function( options ) {
  this.options = options;
  this.wpt = new WPT( this.options.wpt.server );

  this.data  = [];
  this.queue = new Queue();
}
1088945
function Router(options) {
  var self = this;

  options = options || {};

  this.__namespace__ = options.namespace || 'tabex_default_';
  this.__node_id__ = Math.floor(Math.random() * 1e10) + 1;
  this.__last_message_cnt__ = 0;
  this.__handlers__ = [];
  this.__router_channels__ = {};

  // Constants for convenience
  this.__router_id_prefix__ = this.__namespace__ + 'router_';
  this.__router_channels_prefix__ = this.__namespace__ + 'subscribed_';
  this.__lock_prefix__ = this.__namespace__ + 'lock_';

  // IE broadcasts storage events also to the same window, we should filter that messages
  this.__storage_events_filter__ = [];

  for (var i = 0; i < 100; i++) {
    this.__storage_events_filter__.push('');
  }

  this.__ls__ = new LocalStorage();

  // Id of master tab
  this.__master_id__ = null;

  // Handle `localStorage` update
  $$.addEvent(window, 'storage', function (e) {
    if (e.key === null) {
      // If event is caused by `localStorage.clear()` `key` will be null. Skip this
      // event and reestablish normal behaviour by `.__check_master__()` call.
      self.__check_master__();
      return;
    }

    // IE needs kludge because event fire before data was saved
    if ('onstoragecommit' in document) {
      setTimeout(function () {
        self.__on_changed__(e);
      }, 1);

      return;
    }

    self.__on_changed__(e);
  });

  // Handle page unload (listen `onbeforeunload` and `onunload` to ensure that data is stored successfully)
  // http://stackoverflow.com/questions/3775566/javascript-question-onbeforeunload-or-onunload
  //
  this.__destroyed__ = false;
  $$.addEvent(window, 'beforeunload', function () {
    self.__destroy__();
  });
  $$.addEvent(window, 'unload', function () {
    self.__destroy__();
  });

  // Update current tab info and check master alive
  this.__check_master__();

  // Instell timers & remember those to cleanup in __destroy__()
  this.__timer_cm__ = Timer.setInterval(function () {
    self.__check_master__();
  }, UPDATE_INTERVAL);

  // Remove outdated lock records
  this.__timer_lc__ = Timer.setInterval(function () {
    self.__locks_cleanup__();
  }, 1000);
}
762429
function SMTPTransport(options) {
    EventEmitter.call(this);

    options = options || {};
    if (typeof options === 'string') {
        options = {
            url: options
        };
    }

    var urlData;
    var service = options.service;

    if (typeof options.getSocket === 'function') {
        this.getSocket = options.getSocket;
    }

    if (options.url) {
        urlData = shared.parseConnectionUrl(options.url);
        service = service || urlData.service;
    }

    this.options = assign(
        false, // create new object
        options, // regular options
        urlData, // url options
        service && wellknown(service) // wellknown options
    );

    this.logger = shared.getLogger(this.options);

    // temporary object
    var connection = new SMTPConnection(this.options);

    this.name = 'SMTP';
    this.version = packageData.version + '[client:' + connection.version + ']';
}
415757
function(options) {

    var self = this;

    console.log('options are', options);

    this.connected = false;

    this.config = this.getConfig(options);

    this.cbSocketWrapper = new CBSocketWrapper(this.config);

    this.cbSocketWrapper.on('connect', function(message) {
        self.connected = true;
        self.emit('connect');
        logger.log('debug', 'Client connect');
    });

    this.cbSocketWrapper.on('disconnect', function(message) {
        self.connected = false;
        self.emit('disconnect');
    });

    this.cbSocketWrapper.on('message', function(message) {

        self.emit('message', message);

        var source = message.get('source');
        self.emit(source, message);
        //logger.info('CB => Client: ', message)
    });

    // Restart connection process on 'giveUp'
    this.cbSocketWrapper.on('fail', function() {
        self.cbSocketWrapper.giveUp();
        self.connect();
    });

    this.faultTolerantAuth = retry.operation()

    this.connect();
}
42150
function SimpleClient(options) {
    options = options || {};
    this.client = new Zookeeper(options);
    this.root = options.root || '/';
  }
418574
function(options) {
  Data.Graph.call(this, options.schema, options);

  this.containers = {};

  this.addIndex("annotations", {
    types: ["annotation"],
    property: "path"
  });
}
753298
function HttpConnection(options) {
    options = options ?
        ({
            protocol: (options.protocol || 'http:'),
            host: (options.host || 'localhost'),
            port: (options.port || '80'),
            path: httpPath,
            withCredentials: false
        }) :
        ({
            path: 'http://localhost:80' + httpPath
        });
    this.options = util._extend({
        localAddress: process.env.LOCAL_ADDRESS
    }, options);
    this._config = JSON.stringify(this.options);
    if (logger.isDebugEnabled()) {
        logger.debug('created with %s', this._config);
    }
}
548775
function Router () {
  if (!(this instanceof Router)) return new Router();

  var index = 0;

  /**
   * @api public
   */

  function router () {
    router.route.apply(router, slice.call(arguments));
  }

  router.__proto__ = Router.prototype;

  /**
   * Inc the index
   *
   * @api private
   * @return Number
   */

  router.index = function () {
    return index++;
  };

  /**
   * Pushes the socket and arguments through the middleware
   *
   * @api public
   * @param {Error} err *optional
   * @param {Socket} socket
   * @param {Array} args
   * @param {Function} cb
   */

  router.route = function () {
    var args = slice.call(arguments);
    var name = '*';
    var err = null;
    var cb = function () { console.warn('default callback', slice.call(arguments)); };
    var end = function (err) { 
      if (cb.called) return;
      cb.called = new Date(); 
      cb.apply(cb, [err ? err : null].concat(args)); 
    };

    if ('string' === typeof args[0]) name = args.shift();
    if ('object' === typeof args[0] && args[0] instanceof Error) err = args.shift();
    if ('function' === typeof args[args.length - 1]) cb = args.pop();

    var i = 0, path = router.getPath(name), len = path.length;

    debug('got path the length is %s', len);

    (function step (err) {
      
      if (cb.called) return;

      debug('current step %s of %s', i+1, len);

      function next (err) {
        if (++i >= len) {
          end(err);
        }
        else {
          step(err);
        }
      }

      var fn = path[i];
      if (!fn) return next();

      try {
        if (err) {
          if (fn.err) {
            if (fn instanceof Router) {
              fn.route.apply(fn,[name, err].concat(args).concat(next).concat(end));
            }
            else {
              fn.apply(fn, [err].concat(args).concat(next).concat(end));
            }
          }
          else {
            next(err);
          }
        }
        else {
          if (fn.err) {
            next();
          }
          else {
            if (fn instanceof Router) {
              fn.route.apply(fn,[name].concat(args).concat(next).concat(end));
            }
            else {
              fn.apply(fn, args.concat(next).concat(end));
            }
          }
        }
      }
      catch(e) {
        debug('caught error %s', e);
        debug('the fn causing problems', fn);
        console.error(e.stack);
        next(e);
      }
      
    })(err);

  };
  
  return router;

}
992840
function Model(options) {
    this._document = options.document;
    options.document = options.document || {};
    this._handler = options.handler;
    this._id = options._id || options.document._id;
    this.name = options.name || options.document.name;
    this.layers = options.layers || options.document.layers;
    this.epochs = options.epochs || options.document.epochs;
    this.error = options.error || options.document.error;

    if (!(this._id instanceof ObjectID)) {
        this._id = new ObjectID(this._id);
    }

    if (!Array.isArray(this.layers) || this.layers.length < 3) {
        throw new Error('Layers array attribute needs to be at least 3');
    }

    this.filename = __dirname + '/neuralNetwork/' + this.name + '.nnet';
    if (fs.existsSync(this.filename)) {
        this.neuralNetwork = new fann.load(this.filename);
    }
}
695687
function HTTPServer(options) {
  if (!(this instanceof HTTPServer))
    return new HTTPServer(options);

  options = new HTTPOptions(options);

  HTTPBase.call(this, options);

  this.options = options;
  this.network = this.options.network;
  this.logger = this.options.logger.context('http');
  this.node = this.options.node;

  this.chain = this.node.chain;
  this.mempool = this.node.mempool;
  this.pool = this.node.pool;
  this.fees = this.node.fees;
  this.miner = this.node.miner;
  this.rpc = this.node.rpc;

  this.init();
}
325594
function newNetwork(instance, nodesID, nodesName, response) {
  const viewID = misc.uuidv4().slice(0, 8);
  const edgesID = response.workflowID.slice(0, 8);
  return updateItem(instance, item => {
    item.views.push({
      $schema: "https://mojaie.github.io/kiwiii/specs/network_v1.0.json",
      viewID: viewID,
      name: `${nodesName}_${response.name}`,
      viewType: 'network',
      nodes: nodesID,
      edges: edgesID,
      minConnThld: response.query.params.threshold
    });
    item.dataset.push({
      $schema: "https://mojaie.github.io/kiwiii/specs/collection_v1.0.json",
      collectionID: edgesID,
      name: response.name,
      contents: [response]
    });
  }).then(() => viewID);
}
529904
function Http(ip) {
    Http['super_'].call(this);

    /**
     * @property options
     * @private
     * @type {{hostname: String, port: Number, path: String, method: String}}
     */
    this.options = {
        hostname: ip,
        port: 80,
        path: '/rpc',
        method: 'POST',
        headers: {
            'Content-Length': 0
        }
    };
}
154939
def createNetwork(self, data, headers=None, query_params=None, content_type="application/json"):
        
        uri = self.client.base_url + "/network"
        return self.client.post(uri, data, headers, query_params, content_type)
897819
function Server(options) {
  var self = this;
  options = options || {};

  self.serverVersion = '2.0.2';
  self.authKey = "";
  self.protocolVersion = protodef.VersionDummy.Version.V1_0;
  self.minProtocolVersion = 0;
  self.maxProtocolVersion = 0;
  self.port = options['driver-port'] || 28015;

  self._connections = {};
  self.nextConnectionId = 0;

  if (options.debug === true) {
    util._debug = true;
  }
  self.silent = options.silent || constants.SILENT || false;

  self.databases = {};
  self.init();
  self.id = util.uuid();
  self.name = options.name || os.hostname()+util.s4().slice(1);

  self._server = self._createServer();
}