Skip to content

Commit e1c6882

Browse files
authored
fix: transaction broadcast log
1 parent b9a8c4a commit e1c6882

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/api/routes/core-node-rpc-proxy.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,12 @@ export function createCoreNodeRpcProxyRouter(db: DataStore): express.Router {
220220
proxyResp.headers.forEach((value, name) => {
221221
res.setHeader(name, value);
222222
});
223+
if (proxyResp.status === 200) {
224+
// Log the transaction id broadcast, but clone the `Response` first before parsing its body
225+
// so we don't mess up the original response's `ReadableStream` pointers.
226+
const parsedTxId: string = await proxyResp.clone().json();
227+
await logTxBroadcast(parsedTxId);
228+
}
223229
await pipelineAsync(proxyResp.body, res);
224230
}
225231
});

src/tests/v2-proxy-tests.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ describe('v2-proxy tests', () => {
5050
return [apiServer, apiServer.terminate] as const;
5151
},
5252
async (_, __, api) => {
53-
const primaryStubbedResponse = 'success stubbed response';
53+
const primaryStubbedResponse =
54+
'"1659fcdc9167576eb1f2a05d0aaba5ca1aa1943892e7e6e5d3ccb3e537f1c870"';
5455
const extraStubbedResponse = 'extra success stubbed response';
5556
const testRequest = 'fake-tx-data';
5657
let mockedRequestBody = 'none';

0 commit comments

Comments
 (0)