Skip to content

Commit

Permalink
Configure Storage
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayee committed Jun 17, 2018
1 parent 47ecf09 commit 9ef8e47
Show file tree
Hide file tree
Showing 17 changed files with 7,241 additions and 65 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@
/~
js-offs-linux-x64/
js-offs-win32-x64/
js-offs-darwin-x64/

105 changes: 98 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"build-linux-x64": "./node_modules/.bin/electron-packager ./ --platform=linux --arch=x64",
"build-linux-ia36": "./node_modules/.bin/electron-packager ./ --platform=linux --arch=ia36",
"build-windows-x64": "./node_modules/.bin/electron-packager ./ --platform=win32 --arch=x64",
"build-windows-ia36": "./node_modules/.bin/electron-packager ./ --platform=win32 --arch=ia36"
"build-windows-ia36": "./node_modules/.bin/electron-packager ./ --platform=win32 --arch=ia36",
"build-darwin-x64": "./node_modules/.bin/electron-packager ./ --platform=darwin --arch=x64"
},
"author": "Victor Morrow <vijayee.kulkaa@hushmail.com>",
"license": "GPL-3.0",
Expand All @@ -24,6 +25,7 @@
"buffer-split": "1.0.0",
"buffer-xor": "2.0.1",
"clipboard": "1.6.1",
"clipboardy": "^1.2.3",
"collect-stream": "1.1.1",
"cron": "1.1.1",
"cuckoo-filter": "1.0.3",
Expand Down
60 changes: 51 additions & 9 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ let defaults = {
blockPath: '.block-cache',
miniPath: '.mini-cache',
nanoPath: '.nano-cache',
blockCacheSize: 200 * gb,
miniBlockCacheSize: 100 * mb,
nanoBlockCacheSize: 200 * mb,
blockCacheSize: 10 * gb,
miniBlockCacheSize: 10 * gb,
nanoBlockCacheSize: 10 * gb,
nano: 3,
block: 1,
mini: 2,
Expand All @@ -35,7 +35,7 @@ let defaults = {
redundancy: .30, //30% network redundancy target
batchConcurrency: 10,
bootstrap: [
{id: '2A4hXmV7rUk5r3LqGhAY3xbV2GkWubf2Q7QxGLBNy89q', ip: '192.168.1.2', port: 30 }
{id: 'LeW7AX2UhTypMKywe7EHiiAGLnd1tTeqGJ1b7VpLWMr', ip: '73.135.22.132', port: 8200 }
]
}
let _blockPath = new WeakMap()
Expand Down Expand Up @@ -183,14 +183,56 @@ class Config {
return _blockCacheSize.get(this)
}

set blockCacheSize (value) {
if (!Number.isInteger(+value)) {
throw new TypeError("Invalid Block Cache Size")
}
if (value < 300) {
throw new TypeError("Block Cache Size Is Too Small")
}
if (value > (1000000 * mb)) {
throw new TypeError("Block Cache Size Is Too Large")
}
_blockCacheSize.set(this, value)
this.save()
}

get miniBlockCacheSize () {
return _miniBlockCacheSize.get(this)
}

set miniBlockCacheSize (value) {
if (!Number.isInteger(+value)) {
throw new TypeError("Invalid Mini Block Cache Size")
}
if (value < 300) {
throw new TypeError("Mini Block Cache Size Is Too Small")
}
if (value > (1000000 * mb)) {
throw new TypeError("Mini Block Cache Size Is Too Large")
}
_miniBlockCacheSize.set(this, value)
this.save()
}

get nanoBlockCacheSize () {
return _nanoBlockCacheSize.get(this)
}

set nanoBlockCacheSize (value) {
if (!Number.isInteger(+value)) {
throw new TypeError("Invalid Nano Block Cache Size")
}
if (value < 300) {
throw new TypeError("Nano Block Cache Size Is Too Small")
}
if (value > (1000000 * mb)) {
throw new TypeError("Nano Block Cache Size Is Too Large")
}
_nanoBlockCacheSize.set(this, value)
this.save()
}

get nano () {
return _nano.get(this)
}
Expand Down Expand Up @@ -248,10 +290,10 @@ class Config {
}

set httpPort (value) {
if (!Number.isInteger(value)){
if (!Number.isInteger(+value)){
throw new TypeError("Invalid HTTP Port")
}
_startPort.set(this, value)
_httpPort.set(this, value)
this.save()
}

Expand All @@ -260,7 +302,7 @@ class Config {
}

set startPort (value) {
if (!Number.isInteger(value)){
if (!Number.isInteger(+value)){
throw new TypeError("Invalid Port Number")
}
_startPort.set(this, value)
Expand All @@ -272,10 +314,10 @@ class Config {
}

set numPortTries (value) {
if (!Number.isInteger(value)){
if (!Number.isInteger(+value)){
throw new TypeError("Invalid Number of Port Tries")
}
_startPort.set(this, value)
_numPortTries.set(this, value)
this.save()
}

Expand Down
Loading

0 comments on commit 9ef8e47

Please sign in to comment.