mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-05-20 15:39:50 +00:00
add ValidatorData field to Message
Useful for passing data from the validation to the application.
This commit is contained in:
parent
534fe2f382
commit
8b423348a0
@ -151,6 +151,7 @@ type PubSubRouter interface {
|
|||||||
type Message struct {
|
type Message struct {
|
||||||
*pb.Message
|
*pb.Message
|
||||||
ReceivedFrom peer.ID
|
ReceivedFrom peer.ID
|
||||||
|
VaidatorData interface{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Message) GetFrom() peer.ID {
|
func (m *Message) GetFrom() peer.ID {
|
||||||
@ -688,7 +689,7 @@ func (p *PubSub) handleIncomingRPC(rpc *RPC) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
msg := &Message{pmsg, rpc.from}
|
msg := &Message{pmsg, rpc.from, nil}
|
||||||
p.pushMsg(msg)
|
p.pushMsg(msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
2
topic.go
2
topic.go
@ -167,7 +167,7 @@ func (t *Topic) Publish(ctx context.Context, data []byte, opts ...PubOpt) error
|
|||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case t.p.publish <- &Message{m, id}:
|
case t.p.publish <- &Message{m, id, nil}:
|
||||||
case <-t.p.ctx.Done():
|
case <-t.p.ctx.Done():
|
||||||
return t.p.ctx.Err()
|
return t.p.ctx.Err()
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user