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
dd3f38fe
Commit
dd3f38fe
authored
Jan 27, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename transport to ws
Cleanup object naming for clarity
parent
a38bca34
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
10 deletions
+10
-10
cmd.go
cmd/utils/cmd.go
+1
-1
server.go
rpc/ws/server.go
+9
-9
No files found.
cmd/utils/cmd.go
View file @
dd3f38fe
...
@@ -39,7 +39,7 @@ import (
...
@@ -39,7 +39,7 @@ import (
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rlp"
rpchttp
"github.com/ethereum/go-ethereum/rpc/http"
rpchttp
"github.com/ethereum/go-ethereum/rpc/http"
rpcws
"github.com/ethereum/go-ethereum/rpc/w
ebsocket
"
rpcws
"github.com/ethereum/go-ethereum/rpc/w
s
"
"github.com/ethereum/go-ethereum/state"
"github.com/ethereum/go-ethereum/state"
// "github.com/ethereum/go-ethereum/websocket"
// "github.com/ethereum/go-ethereum/websocket"
"github.com/ethereum/go-ethereum/xeth"
"github.com/ethereum/go-ethereum/xeth"
...
...
rpc/w
ebsocket
/server.go
→
rpc/w
s
/server.go
View file @
dd3f38fe
...
@@ -14,14 +14,14 @@
...
@@ -14,14 +14,14 @@
You should have received a copy of the GNU General Public License
You should have received a copy of the GNU General Public License
along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
*/
*/
package
w
ebsocket
package
w
s
import
(
import
(
"fmt"
"fmt"
"net"
"net"
"net/http"
"net/http"
ws
"code.google.com/p/go.net/websocket"
"code.google.com/p/go.net/websocket"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/event/filter"
"github.com/ethereum/go-ethereum/event/filter"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/logger"
...
@@ -88,23 +88,23 @@ func (self *WebSocketServer) Start() {
...
@@ -88,23 +88,23 @@ func (self *WebSocketServer) Start() {
func
(
s
*
WebSocketServer
)
apiHandler
(
xeth
*
rpc
.
EthereumApi
)
http
.
Handler
{
func
(
s
*
WebSocketServer
)
apiHandler
(
xeth
*
rpc
.
EthereumApi
)
http
.
Handler
{
fn
:=
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
fn
:=
func
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
h
:=
sockHandler
(
xeth
)
h
:=
sockHandler
(
xeth
)
s
:=
w
s
.
Server
{
Handler
:
h
}
s
:=
w
ebsocket
.
Server
{
Handler
:
h
}
s
.
ServeHTTP
(
w
,
req
)
s
.
ServeHTTP
(
w
,
req
)
}
}
return
http
.
HandlerFunc
(
fn
)
return
http
.
HandlerFunc
(
fn
)
}
}
func
sockHandler
(
xeth
*
rpc
.
EthereumApi
)
w
s
.
Handler
{
func
sockHandler
(
xeth
*
rpc
.
EthereumApi
)
w
ebsocket
.
Handler
{
fn
:=
func
(
conn
*
w
s
.
Conn
)
{
fn
:=
func
(
conn
*
w
ebsocket
.
Conn
)
{
for
{
for
{
// FIX wslogger does not output to console
// FIX wslogger does not output to console
wslogger
.
Debugln
(
"Handling request"
)
wslogger
.
Debugln
(
"Handling request"
)
var
reqParsed
rpc
.
RpcRequest
var
reqParsed
rpc
.
RpcRequest
if
err
:=
w
s
.
JSON
.
Receive
(
conn
,
&
reqParsed
);
err
!=
nil
{
if
err
:=
w
ebsocket
.
JSON
.
Receive
(
conn
,
&
reqParsed
);
err
!=
nil
{
wslogger
.
Debugln
(
rpc
.
ErrorParseRequest
)
wslogger
.
Debugln
(
rpc
.
ErrorParseRequest
)
w
s
.
JSON
.
Send
(
conn
,
rpc
.
RpcErrorResponse
{
JsonRpc
:
reqParsed
.
JsonRpc
,
ID
:
reqParsed
.
ID
,
Error
:
true
,
ErrorText
:
rpc
.
ErrorParseRequest
})
w
ebsocket
.
JSON
.
Send
(
conn
,
rpc
.
RpcErrorResponse
{
JsonRpc
:
reqParsed
.
JsonRpc
,
ID
:
reqParsed
.
ID
,
Error
:
true
,
ErrorText
:
rpc
.
ErrorParseRequest
})
continue
continue
}
}
...
@@ -112,12 +112,12 @@ func sockHandler(xeth *rpc.EthereumApi) ws.Handler {
...
@@ -112,12 +112,12 @@ func sockHandler(xeth *rpc.EthereumApi) ws.Handler {
reserr
:=
xeth
.
GetRequestReply
(
&
reqParsed
,
&
response
)
reserr
:=
xeth
.
GetRequestReply
(
&
reqParsed
,
&
response
)
if
reserr
!=
nil
{
if
reserr
!=
nil
{
wslogger
.
Errorln
(
reserr
)
wslogger
.
Errorln
(
reserr
)
w
s
.
JSON
.
Send
(
conn
,
rpc
.
RpcErrorResponse
{
JsonRpc
:
reqParsed
.
JsonRpc
,
ID
:
reqParsed
.
ID
,
Error
:
true
,
ErrorText
:
reserr
.
Error
()})
w
ebsocket
.
JSON
.
Send
(
conn
,
rpc
.
RpcErrorResponse
{
JsonRpc
:
reqParsed
.
JsonRpc
,
ID
:
reqParsed
.
ID
,
Error
:
true
,
ErrorText
:
reserr
.
Error
()})
continue
continue
}
}
wslogger
.
Debugf
(
"Generated response: %T %s"
,
response
,
response
)
wslogger
.
Debugf
(
"Generated response: %T %s"
,
response
,
response
)
w
s
.
JSON
.
Send
(
conn
,
rpc
.
RpcSuccessResponse
{
JsonRpc
:
reqParsed
.
JsonRpc
,
ID
:
reqParsed
.
ID
,
Error
:
false
,
Result
:
response
})
w
ebsocket
.
JSON
.
Send
(
conn
,
rpc
.
RpcSuccessResponse
{
JsonRpc
:
reqParsed
.
JsonRpc
,
ID
:
reqParsed
.
ID
,
Error
:
false
,
Result
:
response
})
}
}
}
}
return
fn
return
fn
...
...
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