Skip to content

Commit

Permalink
Revert "tmp: disable ThpAck"
Browse files Browse the repository at this point in the history
This reverts commit 16215cf5e348c532c690abb1f467c93db3cc934b.
  • Loading branch information
szymonlesisz committed Sep 24, 2024
1 parent 7ff2336 commit 6c0b109
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 20 deletions.
13 changes: 4 additions & 9 deletions packages/transport/src/thp/receive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export const receiveThpMessage = async ({
apiWrite,
signal,
}: Omit<ReceiveThpMessageProps, 'messages'>): ReturnType<typeof receive> => {
const recvStart = Date.now();
console.warn('receiveThpMessage start', protocolState);

const decoded = await receive(
Expand All @@ -70,21 +69,17 @@ export const receiveThpMessage = async ({
return decoded;
}

console.warn('receiveThpMessage received', recvStart - Date.now());

const isAckExpected = protocolThp.isAckExpected(protocolState?.expectedResponses || []);
if (isAckExpected) {
const ack = protocolThp.encodeAck(decoded.payload.header);
console.warn('Writing Ack', ack, typeof apiWrite);
// const ackResult = await apiWrite(ack, signal);
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');
// }
Expand Down
15 changes: 4 additions & 11 deletions packages/transport/src/thp/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const sendThpMessage = async ({

const attempt = async (): ReturnType<typeof apiRead> => {
try {
const sendStart = Date.now();
const result = await scheduleAction(
async attemptSignal => {
console.warn('---> sendThpMessage attempt start', tries);
Expand All @@ -44,15 +43,9 @@ export const sendThpMessage = async ({
return sendResult;
}

console.warn(
'...trying to read ack',
typeof readWithExpectedState,
typeof attemptSignal,
);
console.warn('...trying to read ack', tries);

return sendResult;

// return readWithExpectedState(apiRead, protocolState, attemptSignal);
return readWithExpectedState(apiRead, protocolState, attemptSignal);
},
{
signal,
Expand All @@ -68,9 +61,9 @@ export const sendThpMessage = async ({
},
);

console.warn('sendWithRetransmission result', tries, Date.now() - sendStart, result);
console.warn('sendWithRetransmission result', tries, result);

return result as any;
return result;
} catch (error) {
console.warn('sendWithRetransmission error', tries, error);
throw error; // TODO: return { success: false } and handle it in result below
Expand Down

0 comments on commit 6c0b109

Please sign in to comment.