From dc57bfb07ceccc27fd444f1955449f4c71b86eee Mon Sep 17 00:00:00 2001 From: Tomas Olvecky Date: Mon, 16 Nov 2020 17:28:06 +0100 Subject: [PATCH] Implement RAM storage, fix port aliasing using -p switch --- bin/index.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/index.js b/bin/index.js index d02106b..f5bdf86 100755 --- a/bin/index.js +++ b/bin/index.js @@ -4,6 +4,7 @@ const os = require('os') const fs = require('fs').promises const repl = require('repl') const minimist = require('minimist') +const RAM = require('random-access-memory') const { Server, Client } = require('../') const { migrate: migrateFromDaemon, isMigrated } = require('@hyperspace/migration-tool') @@ -21,6 +22,7 @@ const argv = minimist(process.argv.slice(2), { }, alias: { host: 'h', + port: 'p', storage: 's', bootstrap: 'b' } @@ -67,7 +69,11 @@ async function main () { // For now, the storage path is determined as follows: // If ~/.hyperdrive/storage/cores exists, use that (from an old hyperdrive daemon installation) // Else, use ~/.hyperspace/storage - const storage = argv.storage ? argv.storage : await getStoragePath() + const storage = argv['memory-only'] + ? getMemoryStorage() + : argv.storage ? argv.storage : await getStoragePath() + + console.log(`Using '${storage}' for storage`) const s = new Server({ host: argv.host, @@ -144,6 +150,11 @@ async function getStoragePath () { } } +function getMemoryStorage () { + RAM.toString = () => 'RAM' + return RAM +} + function onerror (err) { console.error(err.stack) process.exit(1)