From 1a221d4d37f4bdee1fb45141828e201948e8ddd3 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Sat, 15 Jun 2024 05:46:08 +0200 Subject: fix typos --- jsonrpc/client/message_dispatcher.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'jsonrpc/client/message_dispatcher.go') diff --git a/jsonrpc/client/message_dispatcher.go b/jsonrpc/client/message_dispatcher.go index dab75ca..9177f6e 100644 --- a/jsonrpc/client/message_dispatcher.go +++ b/jsonrpc/client/message_dispatcher.go @@ -40,17 +40,18 @@ func (c *messageDispatcher[K, V]) length() int { return len(c.chans) } -// disptach Disptaches the msg to the channel with the given key -func (c *messageDispatcher[K, V]) disptach(key K, msg V) error { +// dispatch Disptaches the msg to the channel with the given key +func (c *messageDispatcher[K, V]) dispatch(key K, msg V) error { c.Lock() - defer c.Unlock() + ch, ok := c.chans[key] + c.Unlock() - if ch, ok := c.chans[key]; ok { - ch <- msg - return nil + if !ok { + return fmt.Errorf("Channel not found") } - return fmt.Errorf("Channel not found") + ch <- msg + return nil } // unregister Unregisters the channel with the provided key -- cgit v1.2.3