From 1a86c3092ef22427f3baef8de9112054a4f5bef7 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Thu, 29 Aug 2024 18:52:09 +0200 Subject: [PATCH] tmp: disable ThpAck --- packages/transport/src/thp/receive.ts | 15 ++++++++++----- packages/transport/src/thp/send.ts | 15 +++++++++++---- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/packages/transport/src/thp/receive.ts b/packages/transport/src/thp/receive.ts index bee93f837c1..b1384b333cd 100644 --- a/packages/transport/src/thp/receive.ts +++ b/packages/transport/src/thp/receive.ts @@ -59,6 +59,7 @@ export const receiveThpMessage = async ({ apiWrite, signal, }: Omit): Promise => { + const recvStart = Date.now(); console.warn('receiveThpMessage start', protocolState); const decoded = await receive( @@ -66,17 +67,21 @@ export const receiveThpMessage = async ({ v2Protocol, ); + console.warn('receiveThpMessage received', recvStart - Date.now()); + const isAckExpected = protocolThp.isAckExpected(protocolState?.expectedResponses || []); if (isAckExpected) { const ack = protocolThp.encodeAck(decoded.header); - console.warn('Writing Ack', ack); - const ackResult = await apiWrite(ack, signal); + console.warn('Writing Ack', ack, typeof apiWrite); + // const ackResult = await apiWrite(ack, signal); - if (!ackResult.success) { - // TODO: what to do here? - } + // if (!ackResult.success) { + // // TODO: what to do here? + // } } + console.warn('receiveThpMessage end', recvStart - Date.now()); + // if (isAckExpected) { // protocolState?.updateSyncBit('recv'); // } diff --git a/packages/transport/src/thp/send.ts b/packages/transport/src/thp/send.ts index 891b090916c..0666d0d4cb2 100644 --- a/packages/transport/src/thp/send.ts +++ b/packages/transport/src/thp/send.ts @@ -34,6 +34,7 @@ export const sendThpMessage = async ({ const attempt = async (): ReturnType => { try { + const sendStart = Date.now(); const result = await scheduleAction( async attemptSignal => { console.warn('---> sendThpMessage attempt start', tries); @@ -43,9 +44,15 @@ export const sendThpMessage = async ({ return sendResult; } - console.warn('...trying to read ack', tries); + console.warn( + '...trying to read ack', + typeof readWithExpectedState, + typeof attemptSignal, + ); - return readWithExpectedState(apiRead, protocolState, attemptSignal); + return sendResult; + + // return readWithExpectedState(apiRead, protocolState, attemptSignal); }, { signal, @@ -61,9 +68,9 @@ export const sendThpMessage = async ({ }, ); - console.warn('sendWithRetransmission result', tries, result); + console.warn('sendWithRetransmission result', tries, Date.now() - sendStart, result); - return result; + return result as any; } catch (error) { console.warn('sendWithRetransmission error', tries, error); throw error; // TODO: return { success: false } and handle it in result below