feat(mpc-system): optimize party index handling and add gRPC debug logs

- Simplified participant list handling in JoinSession client
- Added debug logging for party_index conversion in gRPC messages
- Removed redundant party filtering logic
- Added detailed logging to trace protobuf field values

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
hailin 2025-12-05 04:00:09 -08:00
parent c9cb5676d0
commit 553ffd365e
2 changed files with 200 additions and 198 deletions

View File

@ -80,21 +80,18 @@ func (c *SessionCoordinatorClient) JoinSession(
} }
// Convert response to SessionInfo // Convert response to SessionInfo
participants := make([]use_cases.ParticipantInfo, 0, len(resp.OtherParties)+1) // Note: OtherParties should include ALL participants (including self) from coordinator
participants := make([]use_cases.ParticipantInfo, len(resp.OtherParties))
for i, p := range resp.OtherParties {
// Debug: Log what we received from gRPC
logger.Info("gRPC client - received party_index from protobuf response",
zap.String("party_id", p.PartyId),
zap.Int32("proto_party_index", p.PartyIndex),
zap.Int("converted_party_index", int(p.PartyIndex)))
// Add self participants[i] = use_cases.ParticipantInfo{
participants = append(participants, use_cases.ParticipantInfo{ PartyID: p.PartyId,
PartyID: partyID, PartyIndex: int(p.PartyIndex),
PartyIndex: findPartyIndex(resp.OtherParties, partyID),
})
// Add other parties
for _, p := range resp.OtherParties {
if p.PartyId != partyID {
participants = append(participants, use_cases.ParticipantInfo{
PartyID: p.PartyId,
PartyIndex: int(p.PartyIndex),
})
} }
} }

View File

@ -150,6 +150,11 @@ func (s *SessionCoordinatorServer) JoinSession(
AppVersion: p.DeviceInfo.AppVersion, AppVersion: p.DeviceInfo.AppVersion,
}, },
} }
// Debug: Log what we're about to send in gRPC response
logger.Info("gRPC JoinSession - setting party_index in protobuf response",
zap.String("party_id", p.PartyID),
zap.Int("source_party_index", p.PartyIndex),
zap.Int32("proto_party_index", otherParties[i].PartyIndex))
} }
return &pb.JoinSessionResponse{ return &pb.JoinSessionResponse{