@@ -45,7 +45,8 @@ type csr struct {
45
45
}
46
46
47
47
type ClientServer struct {
48
- id uint64 // should correpond to the ID given to the manager
48
+ id uint64 // should correpond to the MachineID given to the manager
49
+ addr string
49
50
mu sync.Mutex
50
51
csr map [uint64 ]* csr
51
52
reqChan chan * ClientRequest
@@ -78,7 +79,7 @@ func (srv *ClientServer) AddRequest(broadcastID uint64, clientCtx context.Contex
78
79
79
80
BroadcastID : broadcastID ,
80
81
IsBroadcastClient : true ,
81
- OriginAddr : srv .lis . Addr (). String () ,
82
+ OriginAddr : srv .addr ,
82
83
}
83
84
// we expect one response when we are done
84
85
doneChan := make (chan protoreflect.ProtoMessage , 1 )
@@ -215,7 +216,7 @@ func (s *ClientServer) NodeStream(srv ordering.Gorums_NodeStreamServer) error {
215
216
}
216
217
}
217
218
218
- // NewServer returns a new instance of GorumsServer .
219
+ // NewClientServer returns a new instance of ClientServer .
219
220
// This function is intended for internal Gorums use.
220
221
// You should call `NewServer` in the generated code instead.
221
222
func NewClientServer (lis net.Listener , opts ... ServerOption ) * ClientServer {
@@ -230,6 +231,7 @@ func NewClientServer(lis net.Listener, opts ...ServerOption) *ClientServer {
230
231
ctx , cancel := context .WithCancel (context .Background ())
231
232
srv := & ClientServer {
232
233
id : serverOpts .machineID ,
234
+ addr : serverOpts .listenAddr ,
233
235
ctx : ctx ,
234
236
cancelCtx : cancel ,
235
237
csr : make (map [uint64 ]* csr ),
@@ -251,6 +253,9 @@ func (srv *ClientServer) RegisterHandler(method string, handler requestHandler)
251
253
252
254
// Serve starts serving on the listener.
253
255
func (srv * ClientServer ) Serve (listener net.Listener ) error {
256
+ if srv .addr == "" {
257
+ srv .addr = listener .Addr ().String ()
258
+ }
254
259
return srv .grpcServer .Serve (listener )
255
260
}
256
261
@@ -262,9 +267,6 @@ func createClient(addr string, dialOpts []grpc.DialOption) (*broadcast.Client, e
262
267
opts .grpcDialOpts = dialOpts
263
268
mgr := & RawManager {
264
269
opts : opts ,
265
- /*opts: managerOptions{
266
- grpcDialOpts: dialOpts,
267
- },*/
268
270
}
269
271
node , err := NewRawNode (addr )
270
272
if err != nil {
0 commit comments