add ValidatorData field to Message

Useful for passing data from the validation to the application.
This commit is contained in:
vyzo 2019-11-15 20:16:58 +02:00
parent 534fe2f382
commit 8b423348a0
2 changed files with 3 additions and 2 deletions

View File

@ -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)
} }

View File

@ -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()
} }