Skip to content

Commit

Permalink
Windows Error
Browse files Browse the repository at this point in the history
  • Loading branch information
vijayee committed Jun 19, 2018
1 parent 9ef8e47 commit 2ec34f9
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 24 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
js-offs-linux-x64/
js-offs-win32-x64/
js-offs-darwin-x64/
js-offs-win32-x64.zip
js-offs-win32-x64.zip
js-offs-linux-x64.zip

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
"start": "npm run compile-vue && ./node_modules/.bin/electron .",
"rebuild": "./node_modules/.bin/electron-rebuild",
"build-native": "./node_modules/.bin/electron-packager ./",
"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-darwin-x64": "./node_modules/.bin/electron-packager ./ --platform=darwin --arch=x64"
"build-linux-x64": "./node_modules/.bin/electron-packager ./ --platform=linux --arch=x64 --icon=src/electron/images/off-logo.png --asar=true --overwrite && zip -FS -r js-offs-linux-x64.zip js-offs-linux-x64",
"build-linux-ia36": "./node_modules/.bin/electron-packager ./ --platform=linux --arch=ia36 --icon=src/electron/images/off-logo.png --asar=true --overwrite && zip -FS -r js-offs-linux-ia36.zip js-offs-linux-ia36",
"build-windows-x64": "./node_modules/.bin/electron-packager ./ --platform=win32 --arch=x64 --icon=src/electron/images/off-logo.ico --asar=true --overwrite && zip -FS -r js-offs-win32-x64.zip js-offs-win32-x64",
"build-windows-ia36": "./node_modules/.bin/electron-packager ./ --platform=win32 --arch=ia36 --icon=src/electron/images/off-logo.ico --asar=true --overwrite && zip -FS -r js-offs-win32-ia36.zip js-offs-win32-x64",
"build-darwin-x64": "./node_modules/.bin/electron-packager ./ --platform=darwin --arch=x64 --icon=src/electron/images/off-logo.icns --asar=true --overwrite && zip -FS -r js-offs-darwin-x64.zip js-offs-darwin-x64"
},
"author": "Victor Morrow <vijayee.kulkaa@hushmail.com>",
"license": "GPL-3.0",
Expand Down
5 changes: 2 additions & 3 deletions src/block-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const Block = require('./block')
const util = require('./utility')
const fs = require('fs')
const getSize = require('get-folder-size')
const bs58 = require('bs58')
const hamming = require('hamming-distance')
const CuckooFilter = require('cuckoo-filter').CuckooFilter
let _cacheInterface = new WeakMap()
let _path = new WeakMap()
Expand Down Expand Up @@ -103,9 +105,6 @@ module.exports =
}

load (keys) {
keys = keys.filter((key)=> {
return !this.contains(key)
})
let cacheInterface = _cacheInterface.get(this)
return cacheInterface.load(keys)
}
Expand Down
4 changes: 2 additions & 2 deletions src/block-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ module.exports = class BlockRouter extends EventEmitter {
return cb(err, block.data)
})
}
rpc.closestBlock = (number, filter, hash, type, cb) => {
rpc.closestBlock = (hash, filter, type, cb) => {
let bc
switch (type) {
case 1:
Expand All @@ -174,7 +174,7 @@ module.exports = class BlockRouter extends EventEmitter {
break;
}
let key = bs58.encode(hash)
bc.closestBlock(number, key, filter, cb)
bc.closestBlock(key, filter, cb)
}
rpc.containsValue = (hash, type, cb)=> {
let bc
Expand Down
8 changes: 7 additions & 1 deletion src/bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,16 @@ module.exports = class Bucket extends EventEmitter {
if (!(peer instanceof Peer)) {
throw new Error('Invalid Peer')
}
if (!(peer.id)) {
throw new Error('Invalid Peer')
}
const nodeId = _nodeId.get(this)
if (nodeId.equals(peer.id)) {
return
}
if (!index) {
index = 0
}

if (isNaN(index)) {
throw new Error('Invalid index')
}
Expand Down
2 changes: 1 addition & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let defaults = {
redundancy: .30, //30% network redundancy target
batchConcurrency: 10,
bootstrap: [
{id: 'LeW7AX2UhTypMKywe7EHiiAGLnd1tTeqGJ1b7VpLWMr', ip: '73.135.22.132', port: 8200 }
{id: '8fHecNZCiTxavnfnskySbeAYCd1bcv1SAVyi1mcZqurH', ip: '73.135.22.132', port: 8200 }
]
}
let _blockPath = new WeakMap()
Expand Down
Binary file added src/electron/images/off-logo.icns
Binary file not shown.
Binary file added src/electron/images/off-logo.ico
Binary file not shown.
4 changes: 2 additions & 2 deletions src/electron/views/configuration/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" style="overflow: hidden !important;">
<head>
<meta charset="UTF-8">
<title>Off System: Configuration</title>
Expand All @@ -10,7 +10,7 @@
<link rel="image_src" href="/images/off-logo.gif"/>
</head>

<body>
<body style="overflow: hidden !important;">
<div id="app"></div>
<script>
const ipcRenderer = require('electron').ipcRenderer
Expand Down
4 changes: 2 additions & 2 deletions src/electron/views/connect/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html lang="en" style="overflow: hidden !important;">
<head>
<meta charset="UTF-8">
<title>Off System: Connect to a Peer</title>
Expand All @@ -13,7 +13,7 @@
const Connector = require('../../../connector').rendererConnector
</script>

<body style="overflow:hidden;">
<body style="overflow: hidden !important;">
<div id="app" style="overflow:hidden;"></div>
<script src="index.js"></script>
</body>
Expand Down
24 changes: 21 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,16 @@ function createWindow () {
node.once('ready', () => {
let importWin
let createImportWin = () => {
importWin = new BrowserWindow({ width: 530, height: 304, icon: icon, autoHideMenuBar:true, resizable: false})
let width
let height
if (/^win/.test(process.platform)) {
width = 530
height = 380
} else {
width = 530
height = 304
}
importWin = new BrowserWindow({ width, height, icon: icon, autoHideMenuBar:true, resizable: false})
importWin.on('close', (e) => {
e.preventDefault()
importWin.hide()
Expand Down Expand Up @@ -91,7 +100,16 @@ function createWindow () {
let connectWin
let connector
let createConnectWin = () => {
connectWin = new BrowserWindow({ width: 800, height: 126, icon: icon, autoHideMenuBar:true, resizable: false})
let width
let height
if (/^win/.test(process.platform)) {
width = 800
height = 186
} else {
width = 800
height = 126
}
connectWin = new BrowserWindow({ width, height, icon: icon, autoHideMenuBar:true, resizable: false})
connectWin.on('close', (e) => {
e.preventDefault()
connectWin.hide()
Expand Down Expand Up @@ -135,7 +153,7 @@ function createWindow () {
configurationWin.hide()
})
configurationWin.loadURL(`file://${path.join(__dirname, 'electron', 'views', 'configuration', 'index.html')}`)
//configurationWin.webContents.openDevTools({})
// configurationWin.webContents.openDevTools({})
let setHandler = async (payload) => {
config[payload.key] = payload.value
}
Expand Down
3 changes: 2 additions & 1 deletion src/peer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const isIP = require('is-ip')
const bs58 = require('bs58')
const fs = require('fs')
const path = require('path')
const net = require('net')
let _port = new WeakMap()
let _ip = new WeakMap()
let _id = new WeakMap()
Expand All @@ -13,7 +14,7 @@ module.exports = class Peer {
if (!Buffer.isBuffer(id)) {
throw new Error('Id is not a buffer')
}
if (!isIP(ip)) {
if (!net.isIP(ip)) {
throw new Error('Ip is not a valid address')
}
if (isNaN(port)) {
Expand Down
10 changes: 7 additions & 3 deletions src/readable-off-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@ module.exports = class ReadableOffStream extends Readable {
let doNext = () => {
bc.get(key, next)
}
bc.contains(key, (contains) => {
let testContents = (contains) => {
if (!contains) {
if (flightBox && flightBox.filter.contains(key)) {
flightBox.emitter.on(key, doNext)
flightBox.emitter.on(key, () => {
console.log(key)
bc.contains(key, testContents)
})
} else {
let flightBox = bc.load([ key ])
flightBox.emitter.once(key, doNext)
Expand All @@ -107,7 +110,8 @@ module.exports = class ReadableOffStream extends Readable {
} else {
doNext()
}
})
}
bc.contains(key, testContents)
} else {
return yieldBlock()
}
Expand Down
2 changes: 1 addition & 1 deletion src/rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ module.exports = class RPC extends EventEmitter {
responsepb.comType = Direction.Response
responsepb.from = peer.toJSON()
let type = randompb.type
rpcInterface.closestBlock(Cuckoo.fromCBOR(randompb.filter), pb.from.id, randompb.type, (err, block)=> {
rpcInterface.closestBlock(pb.from.id, Cuckoo.fromCBOR(randompb.filter), randompb.type, (err, block)=> {
if (err) {
responsepb.status = Status.Failure
let response = new RPCProto.RPC(responsepb).encode().toBuffer()
Expand Down

0 comments on commit 2ec34f9

Please sign in to comment.