Skip to content

Commit

Permalink
init rpc server
Browse files Browse the repository at this point in the history
  • Loading branch information
nginnever committed Sep 27, 2016
1 parent b3c3699 commit dfa0142
Show file tree
Hide file tree
Showing 6 changed files with 183 additions and 0 deletions.
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
libOpenCL.so.dylib

.DS_Store
test/repo-tests*

# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
node_modules


55 changes: 55 additions & 0 deletions build/config.gypi
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Do not edit. File was generated by node-gyp's "configure" step
{
"target_defaults": {
"cflags": [],
"default_configuration": "Release",
"defines": [],
"include_dirs": [],
"libraries": []
},
"variables": {
"asan": 0,
"host_arch": "x64",
"icu_data_file": "icudt56l.dat",
"icu_data_in": "../../deps/icu/source/data/in/icudt56l.dat",
"icu_endianness": "l",
"icu_gyp_path": "tools/icu/icu-generic.gyp",
"icu_locales": "en,root",
"icu_path": "./deps/icu",
"icu_small": "true",
"icu_ver_major": "56",
"llvm_version": 0,
"node_byteorder": "little",
"node_enable_v8_vtunejit": "false",
"node_install_npm": "true",
"node_no_browser_globals": "false",
"node_prefix": "/usr/local",
"node_release_urlbase": "https://nodejs.org/download/release/",
"node_shared_http_parser": "false",
"node_shared_libuv": "false",
"node_shared_openssl": "false",
"node_shared_zlib": "false",
"node_tag": "",
"node_use_dtrace": "true",
"node_use_etw": "false",
"node_use_lttng": "false",
"node_use_openssl": "true",
"node_use_perfctr": "false",
"openssl_fips": "",
"openssl_no_asm": 0,
"target_arch": "x64",
"uv_parent_path": "/deps/uv/",
"uv_use_dtrace": "true",
"v8_enable_gdbjit": 0,
"v8_enable_i18n_support": 1,
"v8_no_strict_aliasing": 1,
"v8_optimized_debug": 0,
"v8_random_seed": 0,
"v8_use_snapshot": "true",
"want_separate_host_toolset": 0,
"xcode_version": "7.0",
"nodedir": "/Users/voxelot/.node-gyp/5.11.0",
"copy_dev_lib": "true",
"standalone_static_library": 1
}
}
23 changes: 23 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict'

const nooocl = require('nooocl')
const Server = require('./jsonrpcserver')

const CLHost = nooocl.CLHost

var host = CLHost.createV12()
host = new CLHost(1.2)

// configure hardcoded node
var node = {
cfg: {
jsonrpc: {
enable: true,
password: null
}
}
}

var server = new Server.JsonRpcServer(node)

server.enable()
38 changes: 38 additions & 0 deletions jsonrpcserver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict'

const rpc = require('jsonrpc2')
const logger = require('./logger')

// logger.log('info', 'This is an information message.')
//log settings

// Disable rpc library logging
rpc.Endpoint.trace = function () {
var args = [].slice.apply(arguments)
if (args[0] == "***") {
args = args.slice(1)
}
logger.rpcdbg(args.join(" "))
}

var JsonRpcServer = exports.JsonRpcServer = function JsonRpcServer(node)
{
this.node = node
console.log(node)
//logger.log('error', 'This is an information message.');
}

JsonRpcServer.prototype.enable = function () {
if (this.node.cfg.jsonrpc.enable) {
if (this.node.cfg.jsonrpc.password == null) {
logger.log('error', 'JsonRpcServer(): You must set a JSON-RPC password in the settings.')
return
}
this.rpc = new rpc.Server()
this.rpc.defaultScope = this
this.rpc.enableAuth(this.node.cfg.jsonrpc.username, this.node.cfg.jsonrpc.password)

//this.exposeMethods();
//this.startServer();
}
}
11 changes: 11 additions & 0 deletions logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict'

const winston = require('winston')

var logger = module.exports = new (winston.Logger)({
transports: [
new (winston.transports.Console)({
colorize: 'all'
})
]
});
22 changes: 22 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"name": "zcash-gpu-miner",
"version": "0.0.1",
"description": "an OpenCL javascript equihash miner",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/nginnever/zcash-gpu-miner.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/nginnever/zcash-gpu-miner/issues"
},
"homepage": "https://github.com/nginnever/zcash-gpu-miner#readme",
"dependencies": {
"jsonrpc2": "^0.1.1"
}
}

0 comments on commit dfa0142

Please sign in to comment.