Skip to content

Commit

Permalink
rpc: clean up check for missing methods/subscriptions on handler (eth…
Browse files Browse the repository at this point in the history
  • Loading branch information
jsvisa authored and fjl committed Jul 24, 2018
1 parent fe6a947 commit 68da9aa
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions rpc/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,12 @@ func (s *Server) RegisterName(name string, rcvr interface{}) error {

methods, subscriptions := suitableCallbacks(rcvrVal, svc.typ)

// already a previous service register under given sname, merge methods/subscriptions
if len(methods) == 0 && len(subscriptions) == 0 {
return fmt.Errorf("Service %T doesn't have any suitable methods/subscriptions to expose", rcvr)
}

// already a previous service register under given name, merge methods/subscriptions
if regsvc, present := s.services[name]; present {
if len(methods) == 0 && len(subscriptions) == 0 {
return fmt.Errorf("Service %T doesn't have any suitable methods/subscriptions to expose", rcvr)
}
for _, m := range methods {
regsvc.callbacks[formatName(m.method.Name)] = m
}
Expand All @@ -111,10 +112,6 @@ func (s *Server) RegisterName(name string, rcvr interface{}) error {
svc.name = name
svc.callbacks, svc.subscriptions = methods, subscriptions

if len(svc.callbacks) == 0 && len(svc.subscriptions) == 0 {
return fmt.Errorf("Service %T doesn't have any suitable methods/subscriptions to expose", rcvr)
}

s.services[svc.name] = svc
return nil
}
Expand Down

0 comments on commit 68da9aa

Please sign in to comment.