diff --git a/backend/mpc-system/api/proto/session_coordinator.proto b/backend/mpc-system/api/proto/session_coordinator.proto index c1aceb1c..506c41df 100644 --- a/backend/mpc-system/api/proto/session_coordinator.proto +++ b/backend/mpc-system/api/proto/session_coordinator.proto @@ -82,6 +82,7 @@ message JoinSessionResponse { bool success = 1; SessionInfo session_info = 2; repeated PartyInfo other_parties = 3; + int32 party_index = 4; // This party's assigned index } // SessionInfo contains session information diff --git a/backend/mpc-system/services/message-router/adapters/input/grpc/message_grpc_handler.go b/backend/mpc-system/services/message-router/adapters/input/grpc/message_grpc_handler.go index 7d51fd19..042751d1 100644 --- a/backend/mpc-system/services/message-router/adapters/input/grpc/message_grpc_handler.go +++ b/backend/mpc-system/services/message-router/adapters/input/grpc/message_grpc_handler.go @@ -518,6 +518,9 @@ func (s *MessageRouterServer) JoinSession( } } + // Use party_index directly from coordinator response + resp.PartyIndex = coordResp.PartyIndex + if len(coordResp.OtherParties) > 0 { resp.OtherParties = make([]*pb.PartyInfo, len(coordResp.OtherParties)) for i, p := range coordResp.OtherParties { @@ -525,16 +528,13 @@ func (s *MessageRouterServer) JoinSession( PartyId: p.PartyId, PartyIndex: p.PartyIndex, } - // Find this party's index - if p.PartyId == req.PartyId { - resp.PartyIndex = p.PartyIndex - } } } logger.Info("Proxied JoinSession to coordinator", zap.String("session_id", req.SessionId), zap.String("party_id", req.PartyId), + zap.Int32("party_index", resp.PartyIndex), zap.Bool("success", resp.Success)) return resp, nil diff --git a/backend/mpc-system/services/session-coordinator/adapters/input/grpc/session_grpc_handler.go b/backend/mpc-system/services/session-coordinator/adapters/input/grpc/session_grpc_handler.go index 2f986ed9..8fa0762e 100644 --- a/backend/mpc-system/services/session-coordinator/adapters/input/grpc/session_grpc_handler.go +++ b/backend/mpc-system/services/session-coordinator/adapters/input/grpc/session_grpc_handler.go @@ -251,6 +251,7 @@ func (s *SessionCoordinatorServer) JoinSession( Status: output.SessionInfo.Status, }, OtherParties: otherParties, + PartyIndex: int32(output.PartyIndex), }, nil }