status-go/node/rpc.go
Andrea Maria Piana 2f6b32b1f5 bump version
2021-07-20 10:57:38 +02:00

31 lines
745 B
Go

package node
import (
"reflect"
"unicode"
)
// firstCharToLower converts to first character of name to lowercase.
func firstCharToLower(name string) string {
ret := []rune(name)
if len(ret) > 0 {
ret[0] = unicode.ToLower(ret[0])
}
return string(ret)
}
// addSuitableCallbacks iterates over the methods of the given type and adds them to
// the methods list
// This is taken from go-ethereum services
func addSuitableCallbacks(receiver reflect.Value, namespace string, methods map[string]bool) {
typ := receiver.Type()
for m := 0; m < typ.NumMethod(); m++ {
method := typ.Method(m)
if method.PkgPath != "" {
continue // method not exported
}
name := firstCharToLower(method.Name)
methods[namespace+"_"+name] = true
}
}