Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
45e865d5
Commit
45e865d5
authored
Jun 18, 2019
by
Iuri Matias
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add optioan to specify rpc server option
parent
dc0865fc
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
ethsim
remix-simulator/bin/ethsim
+3
-1
server.js
remix-simulator/src/server.js
+8
-4
No files found.
remix-simulator/bin/ethsim
View file @
45e865d5
...
...
@@ -23,11 +23,13 @@ program
.
option
(
'-p, --port [port]'
,
'specify port'
)
.
option
(
'-b, --ip [host]'
,
'specify host'
)
.
option
(
'-c, --coinbase [coinbase]'
,
'specify host'
)
.
option
(
'--rpc'
,
'run rpc server only'
)
.
parse
(
process
.
argv
)
const
Server
=
require
(
'../src/server'
)
const
server
=
new
Server
({
coinbase
:
program
.
coinbase
||
"0x0000000000000000000000000000000000000000"
coinbase
:
program
.
coinbase
||
"0x0000000000000000000000000000000000000000"
,
rpc
:
program
.
rpc
})
server
.
start
(
program
.
host
||
'127.0.0.1'
,
program
.
port
||
8545
)
remix-simulator/src/server.js
View file @
45e865d5
...
...
@@ -14,6 +14,7 @@ class Server {
}).
catch
((
error
)
=>
{
log
(
error
)
})
this
.
rpcOnly
=
options
.
rpc
;
}
start
(
host
,
port
)
{
...
...
@@ -24,28 +25,31 @@ class Server {
app
.
use
(
bodyParser
.
json
())
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
console
.
dir
(
"/ request"
)
res
.
send
(
'Welcome to remix-simulator'
)
})
if
(
this
.
rpcOnly
)
{
app
.
use
((
req
,
res
)
=>
{
this
.
provider
.
sendAsync
(
req
.
body
,
(
err
,
jsonResponse
)
=>
{
if
(
err
)
{
return
res
.
send
(
JSON
.
stringify
({
error
:
err
}))
return
res
.
send
(
JSON
.
stringify
({
error
:
err
}))
}
res
.
send
(
jsonResponse
)
})
})
}
else
{
app
.
ws
(
'/'
,
(
ws
,
req
)
=>
{
ws
.
on
(
'message'
,
function
(
msg
)
{
ws
.
on
(
'message'
,
(
msg
)
=>
{
this
.
provider
.
sendAsync
(
JSON
.
parse
(
msg
),
(
err
,
jsonResponse
)
=>
{
if
(
err
)
{
return
ws
.
send
(
JSON
.
stringify
({
error
:
err
}))
return
ws
.
send
(
JSON
.
stringify
({
error
:
err
}))
}
ws
.
send
(
JSON
.
stringify
(
jsonResponse
))
})
})
})
}
app
.
listen
(
port
,
host
,
()
=>
log
(
'Remix Simulator listening on port '
+
host
+
':'
+
port
))
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment