aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorDaniel A. Nagy <nagy.da@gmail.com>2015-05-11 18:47:14 +0800
committerDaniel A. Nagy <nagy.da@gmail.com>2015-05-11 18:47:14 +0800
commita9e1d38612cfde56c285a5de5b5bfe5326bdc9b5 (patch)
tree6c16d3e2b216fdf0027a477a8975c9052930e34a /rpc
parent1fe70a66ba2ef0f148affa7a72b4e65023474859 (diff)
parent5176fbc6faaa5e7f0305ad7f2b896c092781deaa (diff)
downloaddexon-a9e1d38612cfde56c285a5de5b5bfe5326bdc9b5.tar.gz
dexon-a9e1d38612cfde56c285a5de5b5bfe5326bdc9b5.tar.zst
dexon-a9e1d38612cfde56c285a5de5b5bfe5326bdc9b5.zip
Merge branch 'develop' of github.com:ethereum/go-ethereum into develop
Conflicts: rpc/jeth.go
Diffstat (limited to 'rpc')
-rw-r--r--rpc/api.go33
-rw-r--r--rpc/http.go2
-rw-r--r--rpc/jeth.go2
-rw-r--r--rpc/types.go16
4 files changed, 52 insertions, 1 deletions
diff --git a/rpc/api.go b/rpc/api.go
index 7fab589f2..309c161ad 100644
--- a/rpc/api.go
+++ b/rpc/api.go
@@ -450,10 +450,18 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
*reply = newHexData(res)
case "shh_version":
+ // Short circuit if whisper is not running
+ if api.xeth().Whisper() == nil {
+ return NewNotAvailableError(req.Method, "whisper offline")
+ }
// Retrieves the currently running whisper protocol version
*reply = api.xeth().WhisperVersion()
case "shh_post":
+ // Short circuit if whisper is not running
+ if api.xeth().Whisper() == nil {
+ return NewNotAvailableError(req.Method, "whisper offline")
+ }
// Injects a new message into the whisper network
args := new(WhisperMessageArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -466,10 +474,18 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
*reply = true
case "shh_newIdentity":
+ // Short circuit if whisper is not running
+ if api.xeth().Whisper() == nil {
+ return NewNotAvailableError(req.Method, "whisper offline")
+ }
// Creates a new whisper identity to use for sending/receiving messages
*reply = api.xeth().Whisper().NewIdentity()
case "shh_hasIdentity":
+ // Short circuit if whisper is not running
+ if api.xeth().Whisper() == nil {
+ return NewNotAvailableError(req.Method, "whisper offline")
+ }
// Checks if an identity if owned or not
args := new(WhisperIdentityArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -478,6 +494,10 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
*reply = api.xeth().Whisper().HasIdentity(args.Identity)
case "shh_newFilter":
+ // Short circuit if whisper is not running
+ if api.xeth().Whisper() == nil {
+ return NewNotAvailableError(req.Method, "whisper offline")
+ }
// Create a new filter to watch and match messages with
args := new(WhisperFilterArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -487,6 +507,10 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
*reply = newHexNum(big.NewInt(int64(id)).Bytes())
case "shh_uninstallFilter":
+ // Short circuit if whisper is not running
+ if api.xeth().Whisper() == nil {
+ return NewNotAvailableError(req.Method, "whisper offline")
+ }
// Remove an existing filter watching messages
args := new(FilterIdArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -495,6 +519,10 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
*reply = api.xeth().UninstallWhisperFilter(args.Id)
case "shh_getFilterChanges":
+ // Short circuit if whisper is not running
+ if api.xeth().Whisper() == nil {
+ return NewNotAvailableError(req.Method, "whisper offline")
+ }
// Retrieve all the new messages arrived since the last request
args := new(FilterIdArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
@@ -503,12 +531,17 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
*reply = api.xeth().WhisperMessagesChanged(args.Id)
case "shh_getMessages":
+ // Short circuit if whisper is not running
+ if api.xeth().Whisper() == nil {
+ return NewNotAvailableError(req.Method, "whisper offline")
+ }
// Retrieve all the cached messages matching a specific, existing filter
args := new(FilterIdArgs)
if err := json.Unmarshal(req.Params, &args); err != nil {
return err
}
*reply = api.xeth().WhisperMessages(args.Id)
+
case "eth_hashrate":
*reply = newHexNum(api.xeth().HashRate())
diff --git a/rpc/http.go b/rpc/http.go
index 4760601d8..c5bb10c80 100644
--- a/rpc/http.go
+++ b/rpc/http.go
@@ -116,7 +116,7 @@ func RpcResponse(api *EthereumApi, request *RpcRequest) *interface{} {
switch reserr.(type) {
case nil:
response = &RpcSuccessResponse{Jsonrpc: jsonrpcver, Id: request.Id, Result: reply}
- case *NotImplementedError:
+ case *NotImplementedError, *NotAvailableError:
jsonerr := &RpcErrorObject{-32601, reserr.Error()}
response = &RpcErrorResponse{Jsonrpc: jsonrpcver, Id: request.Id, Error: jsonerr}
case *DecodeParamError, *InsufficientParamsError, *ValidationError, *InvalidTypeError:
diff --git a/rpc/jeth.go b/rpc/jeth.go
index ad52b72d7..2097ac30d 100644
--- a/rpc/jeth.go
+++ b/rpc/jeth.go
@@ -2,6 +2,7 @@ package rpc
import (
"encoding/json"
+ "fmt"
"github.com/ethereum/go-ethereum/jsre"
"github.com/robertkrimen/otto"
)
@@ -50,6 +51,7 @@ func (self *Jeth) Send(call otto.FunctionCall) (response otto.Value) {
var respif interface{}
err = self.ethApi.GetRequestReply(&req, &respif)
if err != nil {
+ fmt.Println("Error response:", err)
return self.err(call, -32603, err.Error(), req.Id)
}
call.Otto.Set("ret_jsonrpc", jsonrpcver)
diff --git a/rpc/types.go b/rpc/types.go
index 1784759a4..e6eb4f856 100644
--- a/rpc/types.go
+++ b/rpc/types.go
@@ -209,6 +209,22 @@ func NewNotImplementedError(method string) *NotImplementedError {
}
}
+type NotAvailableError struct {
+ Method string
+ Reason string
+}
+
+func (e *NotAvailableError) Error() string {
+ return fmt.Sprintf("%s method not available: %s", e.Method, e.Reason)
+}
+
+func NewNotAvailableError(method string, reason string) *NotAvailableError {
+ return &NotAvailableError{
+ Method: method,
+ Reason: reason,
+ }
+}
+
type DecodeParamError struct {
err string
}
4 +0800 Added benchmarks, security and sysutils to SUBDIR list.' href='/~lantw44/cgit/freebsd-ports/commit/Makefile?id=9d65a68cc5f966bc6ccbf0b30b19d61179a141a3'>9d65a68cc5f9
31fbc892accc
9761756777e8
e60d4861edf5
b478f8421cb4
4697a57a05cb


161c5ae0734f
4697a57a05cb

7ca702f09f29
ccb5cd66a921

742e6c4d2ab4
f252cb58977f
af462755cf0c


73dc85456f3e

f252cb58977f
df0519ed9306
047e50052820
a163079f0d26





f252cb58977f
73dc85456f3e

2a2dffb072e0
3cb42d62d420





415e6d73aa39
3cb42d62d420
fd7d6a00cdb2

075386ef4f0a



261e0c065833
5f5e4053ed1f
261e0c065833

5f5e4053ed1f



261e0c065833


261e0c065833
5f5e4053ed1f
261e0c065833
5f5e4053ed1f
261e0c065833
5f5e4053ed1f


261e0c065833
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
           
 

                   
               
               
                    
                 
             
                 
               
                    
                   
                   


                   
             
               
                
                  
             
                  
              
                


              
               
              

              
              

                 
                  
                
                  
                  
                    
             
             


                    
                     

                      
 

                   
                             
 


                               

                 
                                                   
                                                      
                                                                   





                                                       
                      

                                
                                                                                                                                                                              





                                                               
                                                                                                                                                                                               
      

                          



                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
 
         

                       



                                                                                  


                                                                              
                                           
                         
                                                                              
                                                                      
                                                                              


                                                                                  
      
# $FreeBSD$
#

SUBDIR += archivers
SUBDIR += astro
SUBDIR += audio
SUBDIR += benchmarks
SUBDIR += biology
SUBDIR += cad
SUBDIR += chinese
SUBDIR += comms
SUBDIR += converters
SUBDIR += databases
SUBDIR += deskutils
SUBDIR += devel
SUBDIR += editors
SUBDIR += emulators
SUBDIR += ftp
SUBDIR += games
SUBDIR += german
SUBDIR += graphics
SUBDIR += irc
SUBDIR += japanese
SUBDIR += java
SUBDIR += korean
SUBDIR += lang
SUBDIR += mail
SUBDIR += math
SUBDIR += mbone
SUBDIR += misc
SUBDIR += net
SUBDIR += news
SUBDIR += palm
SUBDIR += print
SUBDIR += russian
SUBDIR += security
SUBDIR += shells
SUBDIR += sysutils
SUBDIR += textproc
SUBDIR += vietnamese
SUBDIR += www
SUBDIR += x11
SUBDIR += x11-clocks
SUBDIR += x11-fm
SUBDIR += x11-fonts
SUBDIR += x11-servers
SUBDIR += x11-toolkits
SUBDIR += x11-wm

PORTSTOP=   yes

.include <bsd.port.subdir.mk>

index:
    @rm -f ${.CURDIR}/INDEX
    @make ${.CURDIR}/INDEX

${.CURDIR}/INDEX:
    @echo -n "Generating INDEX - please wait.."
    @make describe ECHO_MSG="echo > /dev/null" | \
        perl ${.CURDIR}/Tools/make_index > ${.CURDIR}/INDEX
.if !defined(INDEX_NOSORT)
    @sed -e 's./..g' ${.CURDIR}/INDEX | \
        sort -t '|' +1 -2 | \
        sed -e 's../.g' > ${.CURDIR}/INDEX.tmp
    @mv -f ${.CURDIR}/INDEX.tmp ${.CURDIR}/INDEX
.endif
    @echo " Done."

print-index:    ${.CURDIR}/INDEX
    @awk -F\| '{ printf("Port:\t%s\nPath:\t%s\nInfo:\t%s\nMaint:\t%s\nIndex:\t%s\nB-deps:\t%s\nR-deps:\t%s\n\n", $$1, $$2, $$4, $$6, $$7, $$8, $$9); }' < ${.CURDIR}/INDEX

search: ${.CURDIR}/INDEX
.if !defined(key)
    @echo "The search target requires a keyword parameter,"
    @echo "e.g.: \"make search key=somekeyword\""
.else
    @grep -i "${key}" ${.CURDIR}/INDEX | awk -F\| '{ printf("Port:\t%s\nPath:\t%s\nInfo:\t%s\nMaint:\t%s\nIndex:\t%s\nB-deps:\t%s\nR-deps:\t%s\n\n", $$1, $$2, $$4, $$6, $$7, $$8, $$9); }'
.endif

parallel: ${.CURDIR}/INDEX
.for dir in ${SUBDIR}
    @echo "all:: ${dir}-all"
.endfor
    @sed -e 's/|/.tgz|/' ${.CURDIR}/INDEX | awk -F '|' '{me=$$1; here=$$2; bdep=$$8; rdep=$$9; split(here, tmp, "/"); if (bdep != "") { gsub("$$", ".tgz", bdep); gsub(" ", ".tgz ", bdep); } if (rdep != "") { gsub("$$", ".tgz", rdep); gsub(" ", ".tgz ", rdep); } print tmp[4] "-all:: " me; print me ": " bdep " " rdep; printf("\t@/a/asami/portbuild/scripts/pdispatch /a/asami/portbuild/scripts/portbuild %s %s", me, here); if (bdep != "") printf(" %s", bdep); if (rdep != "") printf(" %s", rdep); printf("\n")}'

CVS?= cvs
update:
.if defined(SUP_UPDATE)
.if !defined(PORTSSUPFILE)
    @${ECHO_MSG} "Error: Please define PORTSSUPFILE before doing make update."
    @exit 1
.endif
    @echo "--------------------------------------------------------------"
    @echo ">>> Running ${SUP}"
    @echo "--------------------------------------------------------------"
    @${SUP} ${SUPFLAGS} ${PORTSSUPFILE}
.elif defined(CVS_UPDATE)
    @echo "--------------------------------------------------------------"
    @echo ">>> Updating ${.CURDIR} from cvs repository" ${CVSROOT}
    @echo "--------------------------------------------------------------"
    cd ${.CURDIR}; ${CVS} -q update -P -d
.else
    @${ECHO_MSG} "Error: Please define either SUP_UPDATE or CVS_UPDATE first."
.endif