aboutsummaryrefslogtreecommitdiff
path: root/rpc/service.go
diff options
context:
space:
mode:
authorTed Yin <tederminant@gmail.com>2020-09-18 13:14:29 -0400
committerGitHub <noreply@github.com>2020-09-18 13:14:29 -0400
commitd048937c48753d9eaef771bf71820cf95d79df26 (patch)
tree1a7f65fcd72e77092525ab01625b8b9d365e3e40 /rpc/service.go
parent7d1388c743b4ec8f4a86bea95bfada785dee83f7 (diff)
parent7d8c85cf8895b0f998d8eafb02f99d5b689fcd59 (diff)
Merge pull request #34 from ava-labs/devv0.3.0-rc.5
Dev
Diffstat (limited to 'rpc/service.go')
-rw-r--r--rpc/service.go30
1 files changed, 3 insertions, 27 deletions
diff --git a/rpc/service.go b/rpc/service.go
index ead6fb6..bef891e 100644
--- a/rpc/service.go
+++ b/rpc/service.go
@@ -25,9 +25,8 @@ import (
"strings"
"sync"
"unicode"
- "unicode/utf8"
- "github.com/ava-labs/go-ethereum/log"
+ "github.com/ethereum/go-ethereum/log"
)
var (
@@ -139,16 +138,14 @@ func newCallback(receiver, fn reflect.Value) *callback {
c := &callback{fn: fn, rcvr: receiver, errPos: -1, isSubscribe: isPubSub(fntype)}
// Determine parameter types. They must all be exported or builtin types.
c.makeArgTypes()
- if !allExportedOrBuiltin(c.argTypes) {
- return nil
- }
+
// Verify return types. The function must return at most one error
// and/or one other non-error value.
outs := make([]reflect.Type, fntype.NumOut())
for i := 0; i < fntype.NumOut(); i++ {
outs[i] = fntype.Out(i)
}
- if len(outs) > 2 || !allExportedOrBuiltin(outs) {
+ if len(outs) > 2 {
return nil
}
// If an error is returned, it must be the last returned value.
@@ -218,27 +215,6 @@ func (c *callback) call(ctx context.Context, method string, args []reflect.Value
return results[0].Interface(), nil
}
-// Is this an exported - upper case - name?
-func isExported(name string) bool {
- rune, _ := utf8.DecodeRuneInString(name)
- return unicode.IsUpper(rune)
-}
-
-// Are all those types exported or built-in?
-func allExportedOrBuiltin(types []reflect.Type) bool {
- for _, typ := range types {
- for typ.Kind() == reflect.Ptr {
- typ = typ.Elem()
- }
- // PkgPath will be non-empty even for an exported type,
- // so we need to check the type name as well.
- if !isExported(typ.Name()) && typ.PkgPath() != "" {
- return false
- }
- }
- return true
-}
-
// Is t context.Context or *context.Context?
func isContextType(t reflect.Type) bool {
for t.Kind() == reflect.Ptr {