@@ -15,12 +15,12 @@ import (
15
15
16
16
type Client struct {
17
17
Addr string
18
- SendMsg func (broadcastID uint64 , method string , msg protoreflect.ProtoMessage , timeout time.Duration ) error
18
+ SendMsg func (broadcastID uint64 , method string , msg protoreflect.ProtoMessage , timeout time.Duration , originDigest , originSignature [] byte , originPubKey string ) error
19
19
Close func () error
20
20
}
21
21
22
22
type Router interface {
23
- Send (broadcastID uint64 , addr , method string , req msg ) error
23
+ Send (broadcastID uint64 , addr , method string , originDigest , originSignature [] byte , originPubKey string , req msg ) error
24
24
Connect (addr string )
25
25
}
26
26
@@ -61,15 +61,15 @@ func (r *BroadcastRouter) registerState(state *BroadcastState) {
61
61
62
62
type msg interface {}
63
63
64
- func (r * BroadcastRouter ) Send (broadcastID uint64 , addr , method string , req msg ) error {
64
+ func (r * BroadcastRouter ) Send (broadcastID uint64 , addr , method string , originDigest , originSignature [] byte , originPubKey string , req msg ) error {
65
65
if r .addr == "" {
66
66
panic ("The listen addr on the broadcast server cannot be empty. Use the WithListenAddr() option when creating the server." )
67
67
}
68
68
switch val := req .(type ) {
69
69
case * broadcastMsg :
70
- return r .routeBroadcast (broadcastID , addr , method , val )
70
+ return r .routeBroadcast (broadcastID , addr , method , val , originDigest , originSignature , originPubKey )
71
71
case * reply :
72
- return r .routeClientReply (broadcastID , addr , method , val )
72
+ return r .routeClientReply (broadcastID , addr , method , val , originDigest , originSignature , originPubKey )
73
73
case * cancellation :
74
74
r .canceler (broadcastID , val .srvAddrs )
75
75
return nil
@@ -83,27 +83,27 @@ func (r *BroadcastRouter) Connect(addr string) {
83
83
_ , _ = r .getClient (addr )
84
84
}
85
85
86
- func (r * BroadcastRouter ) routeBroadcast (broadcastID uint64 , addr , method string , msg * broadcastMsg ) error {
86
+ func (r * BroadcastRouter ) routeBroadcast (broadcastID uint64 , addr , method string , msg * broadcastMsg , originDigest , originSignature [] byte , originPubKey string ) error {
87
87
if handler , ok := r .serverHandlers [msg .method ]; ok {
88
88
// it runs an interceptor prior to broadcastCall, hence a different signature.
89
89
// see: (srv *broadcastServer) registerBroadcastFunc(method string).
90
- handler (msg .ctx , msg .request , broadcastID , addr , method , msg .options , r .id , r .addr )
90
+ handler (msg .ctx , msg .request , broadcastID , addr , method , msg .options , r .id , r .addr , originDigest , originSignature , originPubKey )
91
91
return nil
92
92
}
93
93
err := errors .New ("handler not found" )
94
94
r .log ("router (broadcast): could not find handler" , err , logging .BroadcastID (broadcastID ), logging .NodeAddr (addr ), logging .Method (method ))
95
95
return err
96
96
}
97
97
98
- func (r * BroadcastRouter ) routeClientReply (broadcastID uint64 , addr , method string , resp * reply ) error {
98
+ func (r * BroadcastRouter ) routeClientReply (broadcastID uint64 , addr , method string , resp * reply , originDigest , originSignature [] byte , originPubKey string ) error {
99
99
// the client has initiated a broadcast call and the reply should be sent as an RPC
100
100
if _ , ok := r .clientHandlers [method ]; ok && addr != "" {
101
101
client , err := r .getClient (addr )
102
102
if err != nil {
103
103
r .log ("router (reply): could not get client" , err , logging .BroadcastID (broadcastID ), logging .NodeAddr (addr ), logging .Method (method ))
104
104
return err
105
105
}
106
- err = client .SendMsg (broadcastID , method , resp .getResponse (), r .dialTimeout )
106
+ err = client .SendMsg (broadcastID , method , resp .getResponse (), r .dialTimeout , originDigest , originSignature , originPubKey )
107
107
r .log ("router (reply): sending reply to client" , err , logging .BroadcastID (broadcastID ), logging .NodeAddr (addr ), logging .Method (method ))
108
108
return err
109
109
}
0 commit comments