Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add cache control to /extended/v1/tx/:tx_id #1229

Merged
merged 5 commits into from
Jul 7, 2022

Conversation

rafaelcr
Copy link
Collaborator

@rafaelcr rafaelcr commented Jul 6, 2022

Adds ETag header to /extended/v1/tx/:tx_id and /extended/v1/tx/:tx_id/raw.

Since transactions can be in the mempool or in the chain and they can later get re-orged, a new ETagType.transaction was added which builds the ETag using the tx_id, index_block_hash (if any), microblock_hash (if any), and status of the relevant transaction. This way, we'll get the best caching behavior even when the tx may be moved from block to microblock to mempool and back.

Closes #1225

@github-actions
Copy link

github-actions bot commented Jul 6, 2022

@github-actions github-actions bot temporarily deployed to pull request July 6, 2022 20:17 Inactive
@rafaelcr rafaelcr requested a review from zone117x July 6, 2022 21:19
@rafaelcr rafaelcr marked this pull request as ready for review July 6, 2022 21:19
@github-actions github-actions bot temporarily deployed to pull request July 6, 2022 21:20 Inactive
@github-actions github-actions bot temporarily deployed to commit July 6, 2022 21:21 Inactive
@codecov-commenter
Copy link

Codecov Report

Merging #1229 (b60336c) into master (aac13c6) will increase coverage by 0.08%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #1229      +/-   ##
==========================================
+ Coverage   76.16%   76.25%   +0.08%     
==========================================
  Files          96       96              
  Lines        9748     9772      +24     
  Branches     1983     1989       +6     
==========================================
+ Hits         7425     7452      +27     
+ Misses       2209     2207       -2     
+ Partials      114      113       -1     
Impacted Files Coverage Δ
src/datastore/common.ts 80.55% <ø> (ø)
src/api/controllers/cache-controller.ts 97.95% <100.00%> (+0.25%) ⬆️
src/api/controllers/db-controller.ts 80.28% <100.00%> (+0.04%) ⬆️
src/api/routes/tx.ts 79.79% <100.00%> (+0.31%) ⬆️
src/datastore/postgres-store.ts 88.09% <100.00%> (+0.05%) ⬆️
src/helpers.ts 63.48% <0.00%> (+0.36%) ⬆️
src/token-metadata/tokens-contract-handler.ts 83.78% <0.00%> (+0.45%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 30371f9...b60336c. Read the comment docs.

@rafaelcr rafaelcr requested a review from zone117x July 7, 2022 14:59
@github-actions github-actions bot temporarily deployed to pull request July 7, 2022 15:01 Inactive
@github-actions github-actions bot temporarily deployed to commit July 7, 2022 15:01 Inactive
Copy link
Member

@zone117x zone117x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice optimization!

@rafaelcr rafaelcr merged commit 8d5ca2c into master Jul 7, 2022
@rafaelcr rafaelcr deleted the feat/single-tx-cache branch July 7, 2022 15:47
blockstack-devops pushed a commit that referenced this pull request Jul 7, 2022
# [4.1.0](v4.0.4...v4.1.0) (2022-07-07)

### Features

* add cache control to `/extended/v1/tx/:tx_id` ([#1229](#1229)) ([8d5ca2c](8d5ca2c))
@blockstack-devops
Copy link

🎉 This PR is included in version 4.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add cache headers to /extended/v1/tx/:tx_id
4 participants