aboutsummaryrefslogtreecommitdiff
path: root/jsonrpc/client/message_dispatcher.go
diff options
context:
space:
mode:
authorhozan23 <hozan23@karyontech.net>2024-06-15 05:46:08 +0200
committerhozan23 <hozan23@karyontech.net>2024-06-15 05:46:08 +0200
commit1a221d4d37f4bdee1fb45141828e201948e8ddd3 (patch)
treea6ed1a19e98c336bc598d4bfe97fe3965d14e2c8 /jsonrpc/client/message_dispatcher.go
parente9af9bc115e0869570b9b79e1610b2bc08abe5a1 (diff)
fix typos
Diffstat (limited to 'jsonrpc/client/message_dispatcher.go')
-rw-r--r--jsonrpc/client/message_dispatcher.go15
1 files changed, 8 insertions, 7 deletions
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