Skip to content

Commit 7ec15c6

Browse files
committed
Implement RAM storage, fix port aliasing using -p switch
1 parent a4f212c commit 7ec15c6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

bin/index.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const os = require('os')
44
const fs = require('fs').promises
55
const repl = require('repl')
66
const minimist = require('minimist')
7+
const RAM = require('random-access-memory')
78

89
const { Server, Client } = require('../')
910
const { migrate: migrateFromDaemon, isMigrated } = require('@hyperspace/migration-tool')
@@ -21,6 +22,7 @@ const argv = minimist(process.argv.slice(2), {
2122
},
2223
alias: {
2324
host: 'h',
25+
port: 'p',
2426
storage: 's',
2527
bootstrap: 'b'
2628
}
@@ -67,7 +69,10 @@ async function main () {
6769
// For now, the storage path is determined as follows:
6870
// If ~/.hyperdrive/storage/cores exists, use that (from an old hyperdrive daemon installation)
6971
// Else, use ~/.hyperspace/storage
70-
const storage = argv.storage ? argv.storage : await getStoragePath()
72+
const storage = argv['memory-only'] ? getMemoryStorage() :
73+
argv.storage ? argv.storage : await getStoragePath()
74+
75+
console.log(`Using '${storage}' for storage`)
7176

7277
const s = new Server({
7378
host: argv.host,
@@ -144,6 +149,11 @@ async function getStoragePath () {
144149
}
145150
}
146151

152+
function getMemoryStorage () {
153+
RAM.toString = () => "RAM"
154+
return RAM
155+
}
156+
147157
function onerror (err) {
148158
console.error(err.stack)
149159
process.exit(1)

0 commit comments

Comments
 (0)