Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
a26aecdf
Commit
a26aecdf
authored
Jan 06, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated WS API. Fixes #219. Closes #220
parent
47e6b2ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
42 deletions
+38
-42
websockets.go
cmd/utils/websockets.go
+35
-35
client.go
websocket/client.go
+2
-4
message.go
websocket/message.go
+1
-1
server.go
websocket/server.go
+0
-2
No files found.
cmd/utils/websockets.go
View file @
a26aecdf
...
...
@@ -33,73 +33,73 @@ func (self *WebSocketServer) Serv() {
data
:=
ethutil
.
NewValue
(
msg
.
Args
)
bcode
,
err
:=
ethutil
.
Compile
(
data
.
Get
(
0
)
.
Str
(),
false
)
if
err
!=
nil
{
c
.
Write
(
args
(
nil
,
err
.
Error
()),
msg
.
See
d
)
c
.
Write
(
args
(
nil
,
err
.
Error
()),
msg
.
I
d
)
}
code
:=
ethutil
.
Bytes2Hex
(
bcode
)
c
.
Write
(
args
(
code
,
nil
),
msg
.
See
d
)
case
"
getB
lockByNumber"
:
c
.
Write
(
args
(
code
,
nil
),
msg
.
I
d
)
case
"
eth_b
lockByNumber"
:
args
:=
msg
.
Arguments
()
block
:=
pipe
.
BlockByNumber
(
int32
(
args
.
Get
(
0
)
.
Uint
()))
c
.
Write
(
block
,
msg
.
See
d
)
c
.
Write
(
block
,
msg
.
I
d
)
case
"getKey"
:
c
.
Write
(
pipe
.
Key
()
.
PrivateKey
,
msg
.
Seed
)
case
"transact"
:
case
"eth_blockByHash"
:
args
:=
msg
.
Arguments
()
c
.
Write
(
pipe
.
BlockByHash
(
args
.
Get
(
0
)
.
Str
()),
msg
.
Id
)
case
"eth_transact"
:
if
mp
,
ok
:=
msg
.
Args
[
0
]
.
(
map
[
string
]
interface
{});
ok
{
object
:=
mapToTxParams
(
mp
)
c
.
Write
(
args
(
pipe
.
Transact
(
object
[
"from"
]
,
object
[
"to"
],
object
[
"value"
],
object
[
"gas"
],
object
[
"gasPrice"
],
object
[
"data"
])),
msg
.
See
d
,
args
(
pipe
.
Transact
(
pipe
.
Key
()
.
PrivateKey
,
object
[
"to"
],
object
[
"value"
],
object
[
"gas"
],
object
[
"gasPrice"
],
object
[
"data"
])),
msg
.
I
d
,
)
}
case
"getCoinBase"
:
c
.
Write
(
pipe
.
CoinBase
(),
msg
.
Seed
)
case
"eth_gasPrice"
:
c
.
Write
(
"10000000000000"
,
msg
.
Id
)
case
"eth_coinbase"
:
c
.
Write
(
pipe
.
CoinBase
(),
msg
.
Id
)
case
"
getIsL
istening"
:
c
.
Write
(
pipe
.
IsListening
(),
msg
.
See
d
)
case
"
eth_l
istening"
:
c
.
Write
(
pipe
.
IsListening
(),
msg
.
I
d
)
case
"getIsMining"
:
c
.
Write
(
pipe
.
IsMining
(),
msg
.
Seed
)
case
"getPeerCoint"
:
c
.
Write
(
pipe
.
PeerCount
(),
msg
.
Seed
)
case
"getCountAt"
:
args
:=
msg
.
Arguments
()
case
"eth_mining"
:
c
.
Write
(
pipe
.
IsMining
(),
msg
.
Id
)
c
.
Write
(
pipe
.
TxCountAt
(
args
.
Get
(
0
)
.
Str
()),
msg
.
Seed
)
case
"eth_peerCount"
:
c
.
Write
(
pipe
.
PeerCount
(),
msg
.
Id
)
case
"
getCode
At"
:
case
"
eth_count
At"
:
args
:=
msg
.
Arguments
()
c
.
Write
(
len
(
pipe
.
CodeAt
(
args
.
Get
(
0
)
.
Str
())),
msg
.
See
d
)
c
.
Write
(
pipe
.
TxCountAt
(
args
.
Get
(
0
)
.
Str
()),
msg
.
I
d
)
case
"
getBlockByHash
"
:
case
"
eth_codeAt
"
:
args
:=
msg
.
Arguments
()
c
.
Write
(
pipe
.
BlockByHash
(
args
.
Get
(
0
)
.
Str
()),
msg
.
See
d
)
c
.
Write
(
len
(
pipe
.
CodeAt
(
args
.
Get
(
0
)
.
Str
())),
msg
.
I
d
)
case
"
getS
torageAt"
:
case
"
eth_s
torageAt"
:
args
:=
msg
.
Arguments
()
c
.
Write
(
pipe
.
StorageAt
(
args
.
Get
(
0
)
.
Str
(),
args
.
Get
(
1
)
.
Str
()),
msg
.
See
d
)
c
.
Write
(
pipe
.
StorageAt
(
args
.
Get
(
0
)
.
Str
(),
args
.
Get
(
1
)
.
Str
()),
msg
.
I
d
)
case
"
getB
alanceAt"
:
case
"
eth_b
alanceAt"
:
args
:=
msg
.
Arguments
()
c
.
Write
(
pipe
.
BalanceAt
(
args
.
Get
(
0
)
.
Str
()),
msg
.
See
d
)
c
.
Write
(
pipe
.
BalanceAt
(
args
.
Get
(
0
)
.
Str
()),
msg
.
I
d
)
case
"
getS
ecretToAddress"
:
case
"
eth_s
ecretToAddress"
:
args
:=
msg
.
Arguments
()
c
.
Write
(
pipe
.
SecretToAddress
(
args
.
Get
(
0
)
.
Str
()),
msg
.
See
d
)
c
.
Write
(
pipe
.
SecretToAddress
(
args
.
Get
(
0
)
.
Str
()),
msg
.
I
d
)
case
"newFilter"
:
case
"newFilterString"
:
case
"messages"
:
case
"
eth_
newFilter"
:
case
"
eth_
newFilterString"
:
case
"
eth_
messages"
:
// TODO
}
...
...
websocket/client.go
View file @
a26aecdf
...
...
@@ -50,8 +50,8 @@ func (c *Client) Conn() *ws.Conn {
return
c
.
ws
}
func
(
c
*
Client
)
Write
(
data
interface
{},
see
d
int
)
{
msg
:=
&
Message
{
Seed
:
see
d
,
Data
:
data
}
func
(
c
*
Client
)
Write
(
data
interface
{},
i
d
int
)
{
msg
:=
&
Message
{
Id
:
i
d
,
Data
:
data
}
select
{
case
c
.
ch
<-
msg
:
default
:
...
...
@@ -73,7 +73,6 @@ func (c *Client) Listen() {
// Listen write request via chanel
func
(
c
*
Client
)
listenWrite
()
{
wslogger
.
Debugln
(
"Listening write to client"
)
for
{
select
{
...
...
@@ -93,7 +92,6 @@ func (c *Client) listenWrite() {
// Listen read request via chanel
func
(
c
*
Client
)
listenRead
()
{
wslogger
.
Debugln
(
"Listening read from client"
)
for
{
select
{
...
...
websocket/message.go
View file @
a26aecdf
...
...
@@ -5,7 +5,7 @@ import "github.com/ethereum/go-ethereum/ethutil"
type
Message
struct
{
Call
string
`json:"call"`
Args
[]
interface
{}
`json:"args"`
Seed
int
`json:"see
d"`
Id
int
`json:"_i
d"`
Data
interface
{}
`json:"data"`
}
...
...
websocket/server.go
View file @
a26aecdf
...
...
@@ -81,8 +81,6 @@ func (s *Server) MessageFunc(f MsgFunc) {
// Listen and serve.
// It serves client connection and broadcast request.
func
(
s
*
Server
)
Listen
()
{
wslogger
.
Debugln
(
"Listening server..."
)
// ws handler
onConnected
:=
func
(
ws
*
ws
.
Conn
)
{
defer
func
()
{
...
...
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