@@ -22,21 +22,21 @@ var (
2222)
2323
2424type Dispatcher interface {
25- Dispatch (topic string , message any , from string )
25+ Dispatch (topic string , message [] byte , from string )
2626}
2727
2828type DispatcherFuncImpl struct {
29- Dispatcher func (topic string , message any , from string )
29+ Dispatcher func (topic string , message [] byte , from string )
3030}
3131
32- func (d * DispatcherFuncImpl ) Dispatch (topic string , message any , from string ) {
32+ func (d * DispatcherFuncImpl ) Dispatch (topic string , message [] byte , from string ) {
3333 if d .Dispatcher == nil {
3434 return
3535 }
3636 d .Dispatcher (topic , message , from )
3737}
3838
39- func DispatcherFunc (d func (topic string , message any , from string )) Dispatcher {
39+ func DispatcherFunc (d func (topic string , message [] byte , from string )) Dispatcher {
4040 return & DispatcherFuncImpl {Dispatcher : d }
4141}
4242
@@ -122,7 +122,7 @@ func Broadcast(topic string, message []byte, options ...*Option) (err error) {
122122 msgToSend := message
123123
124124 // [messageType: byte] [from: 20 bytes] [msgToSend: ...]
125- msgToSend = append (append ([]byte {byte (messageTypeBroadcast )}, selfIdBytes ... ), msgToSend ... )
125+ msgToSend = append (append ([]byte {byte (MessageTypeBroadcast )}, selfIdBytes ... ), msgToSend ... )
126126
127127 // Check if we have compression enabled
128128 if config .DisableCompression == false {
@@ -178,11 +178,11 @@ func DirectBroadcast(nodeId string, topic string, message []byte, options ...*Op
178178 buf .WriteString (topic )
179179 buf .Write (message )
180180
181- return broadcastMessage (messageTypeDirectBroadcast , "direct:" + nodeId , buf .Bytes (), options ... )
181+ return broadcastMessage (MessageTypeDirectBroadcast , "direct:" + nodeId , buf .Bytes (), options ... )
182182}
183183
184184// Broadcast broadcasts message on given topic across the whole cluster.
185- func broadcastMessage (msgType messageType , topic string , message []byte , options ... * Option ) (err error ) {
185+ func broadcastMessage (msgType MessageType , topic string , message []byte , options ... * Option ) (err error ) {
186186 var config * AdapterConfig
187187 if config = GetAdapter (topic ); config == nil {
188188 return ErrNoAdapter
@@ -210,7 +210,7 @@ func broadcastMessage(msgType messageType, topic string, message []byte, options
210210 msgToSend := buf .Bytes ()
211211
212212 // Check if we have compression enabled
213- if config .DisableCompression == false {
213+ if ! config .DisableCompression {
214214 var compressed []byte
215215 if compressed , err = compressPayload (msgToSend ); err != nil {
216216 slog .Warn (
@@ -224,7 +224,7 @@ func broadcastMessage(msgType messageType, topic string, message []byte, options
224224 }
225225
226226 // Check if we have encryption enabled
227- if config .DisableEncryption == false {
227+ if ! config .DisableEncryption {
228228 keyring := config .Keyring
229229 if keyring == nil {
230230 keyring = globalKeyring
@@ -245,10 +245,10 @@ func broadcastMessage(msgType messageType, topic string, message []byte, options
245245func Dispatch (topic string , message []byte ) {
246246 if config := GetAdapter (topic ); config != nil {
247247 // Read the message type
248- msgType := messageType (message [0 ])
248+ msgType := MessageType (message [0 ])
249249
250250 // Check if the message is encrypted
251- if msgType == messageTypeEncrypt {
251+ if msgType == MessageTypeEncrypt {
252252 if config .DisableEncryption {
253253 slog .Error (
254254 "[chain.pubsub] remote message is encrypted and encryption is not configured" ,
@@ -274,9 +274,9 @@ func Dispatch(topic string, message []byte) {
274274 }
275275
276276 // Reset message type and buf
277- msgType = messageType (plain [0 ])
277+ msgType = MessageType (plain [0 ])
278278 message = plain
279- } else if config .DisableEncryption == false {
279+ } else if ! config .DisableEncryption {
280280 slog .Error (
281281 "[chain.pubsub] encryption is configured but remote message is not encrypted" ,
282282 slog .String ("Topic" , topic ),
@@ -286,7 +286,7 @@ func Dispatch(topic string, message []byte) {
286286 }
287287
288288 // Check if we have a compressed message
289- if msgType == messageTypeCompress {
289+ if msgType == MessageTypeCompress {
290290 decompressed , err := decompressPayload (message )
291291 if err != nil {
292292 slog .Error (
@@ -299,7 +299,7 @@ func Dispatch(topic string, message []byte) {
299299 }
300300
301301 // Reset message type and buf
302- msgType = messageType (decompressed [0 ])
302+ msgType = MessageType (decompressed [0 ])
303303 message = decompressed
304304 }
305305
@@ -334,7 +334,7 @@ func Dispatch(topic string, message []byte) {
334334 message = message [20 :]
335335
336336 // Check if is a direct broadcast
337- if msgType == messageTypeDirectBroadcast {
337+ if msgType == MessageTypeDirectBroadcast {
338338 if topic != directTopic {
339339 slog .Error (
340340 "[chain.pubsub] invalid topic for remote direct broadcast message" ,
@@ -379,7 +379,7 @@ func Dispatch(topic string, message []byte) {
379379 }
380380 topic = string (message [:topicNameLen ])
381381 message = message [topicNameLen :]
382- } else if msgType != messageTypeBroadcast {
382+ } else if msgType != MessageTypeBroadcast {
383383 slog .Error (
384384 "[chain.pubsub] invalid remote message type" ,
385385 slog .String ("Topic" , topic ),
@@ -396,7 +396,7 @@ func Dispatch(topic string, message []byte) {
396396//
397397// `topic` - The topic to broadcast to, ie: `"users:123"`
398398// `message` - The payload of the broadcast
399- func LocalBroadcast (topic string , message any ) {
399+ func LocalBroadcast (topic string , message [] byte ) {
400400 dispatchMessage (topic , message , selfIdString )
401401}
402402
@@ -480,7 +480,7 @@ func scheduleUnsubscribe(topic string) {
480480}
481481
482482// dispatchMessage deliver the message locally
483- func dispatchMessage (topic string , message any , from string ) {
483+ func dispatchMessage (topic string , message [] byte , from string ) {
484484 go func () {
485485 if from == "" {
486486 from = selfIdString
0 commit comments