mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-29 01:12:24 +08:00
allow service to have nil handler
@perfmode this means we can create a Service first, give it to the network and protocol (removing interdep).
This commit is contained in:

committed by
Brian Tiger Chow

parent
5426a1b512
commit
f9650a7906
@ -161,6 +161,11 @@ func (s *Service) handleIncomingMessage(ctx context.Context, m msg.NetMessage) {
|
|||||||
|
|
||||||
// if it's a request (or has no RequestID), handle it
|
// if it's a request (or has no RequestID), handle it
|
||||||
if rid == nil || rid.IsRequest() {
|
if rid == nil || rid.IsRequest() {
|
||||||
|
if s.Handler == nil {
|
||||||
|
u.PErr("service dropped msg: %v\n", m)
|
||||||
|
return // no handler, drop it.
|
||||||
|
}
|
||||||
|
|
||||||
r1, err := s.Handler.HandleMessage(ctx, m2)
|
r1, err := s.Handler.HandleMessage(ctx, m2)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
u.PErr("handled message yielded error %v\n", err)
|
u.PErr("handled message yielded error %v\n", err)
|
||||||
|
Reference in New Issue
Block a user