Skip to content

Commit

Permalink
More performant critical path
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBCarter committed Jan 29, 2024
1 parent 06c08dd commit 5ac80ef
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,19 @@ describe('HttpBridge.caching', () => {
for (const command of commands.filter(isQueryBoundWitness)) {
// Ensure the query is addressed to the destination
const { destination: commandDestination } = command.$meta as { destination?: string[] }
// TODO: Check supported query using index of query => payload_schemas
if (divinerQuery && commandDestination?.includes(destination.address)) {
// Get the associated payloads
const commandPayloads = await PayloadBuilder.toDataHashMap(await commandArchivist.get(command.payload_hashes))
const query = commandPayloads?.[command.query] as Payload<QueryFields>
// If the destination can process this type of query
if (destination.queries.includes(query.schema)) {
// Issue the query against module
response = await destination.query(command, Object.values(commandPayloads))
expect(response).toBeDefined()
if (commandDestination && commandDestination?.includes(destination.address)) {
// Find the query
const queryIndex = command.payload_hashes.indexOf(command.query)
if (queryIndex !== -1) {
const querySchema = command.payload_schemas[queryIndex]
if (destination.queries.includes(querySchema)) {
// Get the associated payloads
const commandPayloads = await commandArchivist.get(command.payload_hashes)
// If the destination can process this type of query
// Issue the query against module
response = await destination.query(command, commandPayloads)
expect(response).toBeDefined()
}
}
}
}
Expand Down

0 comments on commit 5ac80ef

Please sign in to comment.