Beispiel #1
0
const startGeth = function* () {
    let gethPath;

    const config = JSON.parse(
        fs.readFileSync(path.join('clientBinaries.json')).toString()
    );
    const manager = new ClientBinaryManager(config);
    yield manager.init();

    if (manager.clients.Geth.state.available) {
        gethPath = manager.clients.Geth.activeCli.fullPath;
    }
    else {
        console.info('Downloading geth...');
        let downloadedGeth = yield manager.download('Geth');
        gethPath = downloadedGeth.client.activeCli.fullPath;
        console.info('Geth downloaded at:', gethPath);
    }

    const geth = gethPrivate({
        gethPath,
        balance: 5,
        genesisBlock: {
            difficulty: '0x1',
            extraData: '0x1',
        },
        gethOptions: {
            port: 58546,
            rpcport: 58545,
        },
    });
    yield geth.start();
    return geth;
};
Beispiel #2
0
              return Q.map(_.values(clients), c => {
                binariesDownloaded = true;

                return mgr.download(c.id, {
                  downloadFolder: path.join(Settings.userDataPath, 'binaries'),
                  urlRegex: ALLOWED_DOWNLOAD_URLS_REGEX
                });
              });
Beispiel #3
0
      .then(localConfig => {
        if (!localConfig) {
          log.info(
            'No config for the ClientBinaryManager could be loaded, using local clientBinaries.json.'
          );

          const localConfigPath = path.join(
            Settings.userDataPath,
            'clientBinaries.json'
          );
          localConfig = fs.existsSync(localConfigPath)
            ? require(localConfigPath)
            : require('../clientBinaries.json'); // eslint-disable-line no-param-reassign, global-require, import/no-dynamic-require, import/no-unresolved
        }

        // scan for node
        const mgr = new ClientBinaryManager(localConfig);
        mgr.logger = log;

        this._emit('scanning', 'Scanning for binaries');

        return mgr
          .init({
            folders: [
              path.join(Settings.userDataPath, 'binaries', 'Geth', 'unpacked'),
              path.join(Settings.userDataPath, 'binaries', 'Eth', 'unpacked')
            ]
          })
          .then(() => {
            const clients = mgr.clients;

            this._availableClients = {};

            const available = _.filter(clients, c => !!c.state.available);

            if (!available.length) {
              if (_.isEmpty(clients)) {
                throw new Error(
                  'No client binaries available for this system!'
                );
              }

              this._emit('downloading', 'Downloading binaries');

              return Q.map(_.values(clients), c => {
                binariesDownloaded = true;

                return mgr.download(c.id, {
                  downloadFolder: path.join(Settings.userDataPath, 'binaries'),
                  urlRegex: ALLOWED_DOWNLOAD_URLS_REGEX
                });
              });
            }
          })
          .then(() => {
            this._emit('filtering', 'Filtering available clients');

            _.each(mgr.clients, client => {
              if (client.state.available) {
                const idlcase = client.id.toLowerCase();

                this._availableClients[idlcase] = {
                  binPath:
                    Settings[`${idlcase}Path`] || client.activeCli.fullPath,
                  version: client.version
                };
              }
            });

            // restart if it downloaded while running
            if (restart && binariesDownloaded) {
              log.info('Restarting app ...');
              app.relaunch();
              app.quit();
            }

            this._emit('done');
          });
      })