fix(service-party-app): 切换 session 时重新订阅消息流
问题: - prepareForKeygen 只检查 isPrepared 标志 - 当旧 session 失败后 isPrepared 可能仍为 true - 新 session 调用 prepareForKeygen 时直接跳过,没有重新订阅 - 导致 external party 仍订阅旧 session 的消息流 - server parties 发送的 TSS 消息无法到达 external party 修复: - 检查 sessionId 是否变化 - 如果是新 session,先取消旧订阅再重新订阅 Generated with Claude Code Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
989364969d
commit
fb1b27e36f
|
|
@ -123,11 +123,20 @@ export class TSSHandler extends EventEmitter {
|
|||
* @param partyId 自己的 party ID
|
||||
*/
|
||||
prepareForKeygen(sessionId: string, partyId: string): void {
|
||||
if (this.isPrepared) {
|
||||
console.log('[TSS] Already prepared for keygen, skip');
|
||||
// 如果已经为同一个 session 准备过,跳过
|
||||
if (this.isPrepared && this.sessionId === sessionId) {
|
||||
console.log('[TSS] Already prepared for same session, skip');
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果为不同的 session 准备过,先取消旧的订阅
|
||||
if (this.isPrepared && this.sessionId !== sessionId) {
|
||||
console.log(`[TSS] Switching from session ${this.sessionId?.substring(0, 8)}... to ${sessionId.substring(0, 8)}...`);
|
||||
this.grpcClient.removeAllListeners('mpcMessage');
|
||||
this.grpcClient.unsubscribeMessages();
|
||||
this.messageBuffer = [];
|
||||
}
|
||||
|
||||
console.log(`[TSS] Preparing for keygen: session=${sessionId.substring(0, 8)}..., party=${partyId.substring(0, 8)}...`);
|
||||
|
||||
this.sessionId = sessionId;
|
||||
|
|
|
|||
Loading…
Reference in New Issue